/**/
#include <cstdio>
#include <cstring>
#include <cmath>
#include <cctype>
#include <iostream>
#include <algorithm>
#include <map>
#include <set>
#include <vector>
#include <string>
#include <stack>
#include <queue>
typedef long long LL;
using namespace std;
LL n, m;
LL gcd(LL x, LL y){
return y ? gcd(y, x % y) : x;
}
int main()
{
//freopen("in.txt", "r", stdin);
//freopen("out.txt", "w", stdout);
int t;
scanf("%d", &t);
while(t--){
scanf("%lld %lld", &m, &n);
if(gcd(m, n) == 1){
printf("NO\n");
}else{
printf("YES\n");
}
}
return 0;
}
/**/