#include <bits/stdc++.h>
using namespace std;
map<long long, int> mp;
int main() {
  int n, a, b;
  cin >> n;
  int tmp;
  for (int i = 1; i * (long long)i * (long long)i <= 1000000000000000000LL; i++)
    mp[i * (long long)i * (long long)i] = i, tmp = i;
  while (n--) {
    scanf("%d%d", &a, &b);
    if (!mp.count(a * (long long)b))
      puts("No");
    else {
      int c = mp[a * (long long)b];
      if (a % c == 0 && b % c == 0)
        puts("Yes");
      else
        puts("No");
    }
  }
  return 0;
}
