import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.OutputStreamWriter;
import java.io.PrintWriter;
import java.math.BigInteger;
import java.util.StringTokenizer;
import java.util.logging.Level;
import java.util.logging.Logger;
public class B {
final static FastReader reader = new FastReader();
final static PrintWriter writer = new PrintWriter(new OutputStreamWriter(System.out));
public static void main(String[] args) {
B clazz = new B();
int t = reader.nextInt();
for (int i = 0; i < t; i++)
writer.println(clazz.solve(reader.nextInt(), reader.nextInt()) ? "YES" : "NO");
reader.close();
writer.flush();
writer.close();
}
boolean solve(int A, int B) {
double sqrtA = Math.sqrt(A);
double sqrtB = Math.sqrt(B);
return !(Math.floor(sqrtB) == Math.floor(sqrtA));
}
static class FastReader {
BufferedReader reader;
StringTokenizer tokenizer;
public FastReader() {
this.reader = new BufferedReader(new InputStreamReader(System.in));
this.tokenizer = null;
}
String next() {
while (tokenizer == null || !tokenizer.hasMoreElements()) {
try {
tokenizer = new StringTokenizer(reader.readLine());
} catch (Exception e) {
}
}
return tokenizer.nextToken();
}
String nextLine() {
try {
return reader.readLine();
} catch (IOException ex) {
}
return null;
}
int nextInt() {
return Integer.parseInt(next());
}
long nextLong() {
return Long.parseLong(next());
}
BigInteger nextBigInt() {
return new BigInteger(next());
}
void close() {
try {
reader.close();
} catch (IOException ex) {
Logger.getLogger(A.class.getName()).log(Level.SEVERE, null, ex);
}
reader = null;
tokenizer = null;
}
}
}