#include <bits/stdc++.h>
using namespace std;
inline void io() {
  freopen("input.txt", "r", stdin);
  freopen("output.txt", "w", stdout);
}
void PV(vector<long long> v) {
  for (long long i = 0; i < (long long)v.size(); i++) cout << v[i] << " ";
  cout << "\n";
}
void PA(long long v[], long long n, long long x = 0) {
  for (long long i = x; i < n + x; i++) cout << v[i] << " ";
  cout << "\n";
}
void IA(long long a[], long long n, long long x = 0) {
  for (long long i = x; i < n + x; i++) cin >> a[i];
}
const long long N = 5e3 + 7, Mod = 1e9 + 7, INF = 1e9 + 7;
long long n;
long long cr() {
  long long l = 0, r = 1e6 + 7;
  while (l <= r) {
    long long m = (l + r) / 2;
    long long k = m * m * m;
    if (k == n) {
      return m;
    }
    if (k > n) {
      r = m - 1;
    } else {
      if (l == m) m++;
      l = m;
    }
  }
  return 0;
}
void solve() {
  long long a, b;
  cin >> a >> b;
  n = a * b;
  long long l = cr();
  if (l) {
    if (a % l == 0 && b % l == 0) {
      cout << "YES\n";
      return;
    }
  }
  {
    cout << "No\n";
    return;
  }
}
signed main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  long long t1 = 1;
  cin >> t1;
  while (t1--) {
    solve();
  }
}
