- Practice
- Mathematics
- Number Theory
- Euler's Criterion

# Euler's Criterion

# Euler's Criterion

Your friend gives you an equation and asks you to find an integer solution for .

However, you know your friend's mischievous nature and suspect that there is no solution to such an equation. Thus, you first want to find out whether there is a solution to it.

You may find this link helpful: http://mathworld.wolfram.com/EulersCriterion.html

**Input Format**

The first line contains the number of cases, . lines follow, each containing two integers and separated by a single space.

**Constraints**

- , is prime

**Output Format**

Output lines, each containing one word: `YES`

, if a solution exists and `NO`

otherwise.

**Sample Input**

```
2
5 7
4 7
```

**Sample Output**

```
NO
YES
```

**Explanation**

In the second test case, we can take , as . Or we can take , as .

However there is no integer which gives modulo when squared.