Given a positive integer y and a prime p, you are asked to find an integer x such that . If such x exists, output any x mod p. Otherwise, output -1.
Hint: For any integer a and positive integer b, a mod b is the remainder of a dividing b. Remind that a mod b is non-negative!
The first line of input contains a positive integer T, which is the number of test cases.
For each test case, there will be one line containing 2 positive integers y, p., p is guaranteed to be a prime)
Output one integer for each test case. If such x exists, output any x mod p. Otherwise, output -1.