###题目
http://codeforces.com/contest/834/problem/C
###题解
#####先用GCD求出x,y的最小公倍数z
#####再求得p=x/z,q=y/z;
#####若x%pp == 0 && y%qq==0且z/p*q可开1/3次方为整数,则为Yes,否则为No
###注意点
#####scanf("%lld%lld",&x,&y);//cin,cout影响输入速度会t
#####LL c =ceil( pow(a1.0, 1.0/3)),d =ceil(pow(b1.0, 1.0/3));//调整精度
###AC代码
#include <bits/stdc++.h>
#define INF 0x3f3f3f3f
#define maxn 50000 + 10
#define For(a,b) for(int i = a; i < b; i++)
typedef long long LL;
using namespace std;
int a[maxn];
LL gcd(LL a,LL b)
{
if(a%b == 0) return b;
else return gcd(b,a%b);
}
int main()
{
int n;
scanf("%d",&n);
while(n--)
{
LL x,y,z;
LL p,q;
scanf("%I64d%I64d",&x,&y);
z = gcd(x,y);
p = x/z;
q = y/z;
if(x % (p*p) == 0 && y % (q*q) == 0)
{
LL a = x/(p*p*q),b = y/(q*q*p);
LL c =ceil( pow(a*1.0, 1.0/3)),d =ceil(pow(b*1.0, 1.0/3));
if(c*c*c == a && d*d*d == b)
printf("Yes\n");
else printf("No\n");
}
else printf("No\n");
}
return 0;
}