#include <bits/stdc++.h>
using namespace std;
void solve() {
  long long int a, b;
  cin >> a >> b;
  long long int prod = a * b;
  long long int l = 1;
  long long int r = 1e6;
  long long int mid;
  while (l <= r) {
    mid = (l + r) / 2;
    if (mid * mid * mid == prod) {
      break;
    }
    if (mid * mid * mid < prod) {
      l = mid + 1;
    } else {
      r = mid - 1;
    }
  }
  if (mid * mid * mid == prod && a % mid == 0 && b % mid == 0) {
    cout << "YES"
         << "\n";
  } else {
    cout << "NO"
         << "\n";
  }
}
signed main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  long long int t = 1;
  cin >> t;
  while (t--) {
    solve();
  }
  return 0;
}
