#include <bits/stdc++.h>
using namespace std;
const int N = 1e6 + 16;
int lpf[N];
void init() {
  memset(lpf, -1, sizeof(lpf));
  for (int n = 2; n < N; n++) {
    if (lpf[n] == -1) {
      lpf[n] = n;
      if (n < N / n) {
        for (int m = n * n; m < N; m += n) {
          if (lpf[m] == -1) lpf[m] = n;
        }
      }
    }
  }
}
inline int cbrt(long long n) {
  int lo = 1, hi = 1000000;
  while (lo <= hi) {
    int mi = (lo + hi) / 2;
    long long tmp = mi * 1LL * mi * mi;
    if (tmp < n)
      lo = mi + 1;
    else if (tmp > n)
      hi = mi - 1;
    else
      return mi;
  }
  return -1;
}
int main() {
  ios::sync_with_stdio(false);
  cin.tie(NULL);
  cout << setprecision(32);
  init();
  int n;
  cin >> n;
  while (n--) {
    long long a, b;
    cin >> a >> b;
    int x = cbrt(a * b);
    if (x == -1) {
      cout << "No" << '\n';
    } else {
      bool flg = true;
      while (x > 1) {
        int p = lpf[x];
        while (x % p == 0) {
          x /= p;
        }
        int cnt1 = 0;
        int cnt2 = 0;
        while (a % p == 0) {
          a /= p;
          cnt1++;
        }
        while (b % p == 0) {
          b /= p;
          cnt2++;
        }
        int x = (cnt1 + cnt2) / 3;
        if (x > cnt1 || x > cnt2) {
          flg = false;
          break;
        }
      }
      if (flg)
        cout << "Yes" << '\n';
      else
        cout << "No" << '\n';
    }
  }
  return 0;
}
