Quadratic equation 1#3234

Quadratic equation 1

2 seconds
64 megabytes
Easy

Given the quadratic equation a x^2 + b x + c \equiv 0 \pmod{p}, where a > 0 and is an odd prime number.

Your task is to determine whether it has a solution in integers.

Input

The first line of the input file contains the number of tests (1 \leq t \leq 100000). Each test consists of one line containing four integers , , , , separated by a space (3 \leq p \leq 2 \cdot 10^9, 0 < a \leq p - 1, 0 \leq b, c \leq p - 1). It is guaranteed that the input data satisfy the condition described in the problem constraints.

Output

For each test case output a line containing "YES" if the equation has a solution, and "NO" otherwise.

Examples

Example 1

Loading
Loading