#include"iostream"
#include"stdio.h"
#include"algorithm"
using namespace std;
int main()
{
int num;
int i,a,b,sum_a,sum_b;
scanf("%d",&num);
while(num--)
{
sum_a=0;
sum_b=0;
scanf("%d%d",&a,&b);
for(i=1;i
{
if(a%i==0)
sum_a+=i;
}
for(i=1;i
{
if(b%i==0)
sum_b+=i;
}
if(sum_a==b && sum_b==a)
printf("YES\n");
else printf("NO\n");
}
}