Quadratic equation 2#3245

Quadratic equation 2

5 seconds
64 megabytes
Hard

Given the quadratic equation ax^2 + bx + c \equiv 0 \pmod{n}, where , — odd natural numbers. It is guaranteed that b^2-4ac is relatively prime to . Your task is to solve it in integers.

Input

The first line of the input file contains the number of tests (1 \le t \le 100). Each test consists of one line containing four integers , , , , separated by a space (3 \le n \le 10^8, 0 \le a, b, c \le n - 1).

Output

For each test case output a string containing all the roots of the range [0, n-1]. Output the roots separated by spaces in ascending order (note that in the end of the line space is not needed). If there are no roots for the current test, output "NO SOLUTION" without the quotes.

Examples

Example 1

Loading
Loading