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
The first line contains the number of cases, . lines follow, each containing two integers and separated by a single space.
Output lines, each containing one word: YES, if a solution exists and NO otherwise.
In the second test case, we can take , as . Or we can take , as .
However there is no integer which gives modulo when squared.