You can't get around this problem. If n is prime, just take xj to be an element with order pj^aj.
Fortunately though, you don't need to. Just consider the condition for one value of j at a time. What does it tell you about the power of pj that appears in phi(n)?