import java.util.HashMap;
import java.util.Map;
import java.util.Scanner;
public class Main {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
int T = sc.nextInt();
Integer x;
Integer y;
int value = 2;
int key = 1;
Map<Integer,Integer> map = new HashMap<>();
Main main = new Main();
for(int i = 0;i < T;i++){
x = sc.nextInt();
y = sc.nextInt();
while(!(map.containsKey(x) && map.containsKey(y))){
if(main.judge(value)){
map.put(key, value);
key++;
}
value++;
}
main.yiHuo(x, y,map);
}
}
boolean judge(int i) {
if (i <= 1) {
return false;
}
for (int j = 2; j <= i - 1; j++) {
if (i % j == 0) {
return false;
}
}
return true;
}
void yiHuo(Integer x,Integer y,Map map){
String no1 = Integer.toBinaryString((Integer) map.get(x));
String no2 = Integer.toBinaryString((Integer) map.get(y));
if(no1.length() != no2.length()){
System.out.println("No");
} else if (no1.substring(0,no1.length()-1).equals(no2.substring(0,no2.length()-1))) {
if(!(no1.substring(no1.length()-1).equals(no2.substring(no2.length()-1)))){
System.out.println("Yes");
}
}
}
}