#include <bits/stdc++.h>
using namespace std;
bool prime[350005];
int gcd(int q, int w) {
  while (q != 0) {
    w %= q;
    swap(q, w);
  }
  return w;
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  int n;
  cin >> n;
  for (int i = 0; i < n; i++) {
    long long a, b;
    cin >> a >> b;
    if (a > b) {
      swap(a, b);
    }
    long long x = a * b;
    long long l = 0, r = (sqrt(x) + 1);
    while (r - l > 1) {
      long long m = (r + l) / 2;
      if ((m >= 1e6) || (m * m * m >= x)) {
        r = m;
      } else {
        l = m;
      }
    }
    if (r * r * r != x) {
      cout << "No";
      cout << '\n';
      continue;
    }
    long long g = gcd(a, b);
    a /= g;
    b /= g;
    if ((g % a == 0) && (g % b == 0)) {
      cout << "Yes";
    } else {
      cout << "NO";
    }
    cout << '\n';
  }
  return 0;
}
