#include<iostream>
using namespace std;
int main()
{
int n,i;
cin>>n;
for(i=1;i<=n;i++)
{
int a,b,sum=0,j;
cin>>a>>b;
for(j=1;j<a;j++)
if(a%j==0)
sum+=j;
if(sum==b)cout<<"YES"<<endl;
else cout<<"NO"<<endl;
}
}
using namespace std;
int main()
{
int n,i;
cin>>n;
for(i=1;i<=n;i++)
{
int a,b,sum=0,j;
cin>>a>>b;
for(j=1;j<a;j++)
if(a%j==0)
sum+=j;
if(sum==b)cout<<"YES"<<endl;
else cout<<"NO"<<endl;
}
}