Cuberoot This

Given a prime p, and a constant 0 < a < p. Find all x such that x3 ≡ a(modp). Input Each input is on one line (≤ 1000 inputs), with a and p (p < 1000). Output Output all x < p satisfying the condition above in increasing order. Print a blank line if there are none. Sample Input 2 31 Sample Output 4 7 20