#include <bits/stdc++.h>
#pragma GCC optimize("Ofast")
#pragma GCC optimize("no-stack-protector")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#pragma GCC optimize("unroll-loops")
using namespace std;
void seriy() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
}
const double EPS = 1e-8;
signed main() {
  seriy();
  long long n;
  cin >> n;
  for (long long i = 0; i < n; i++) {
    long long a = 0, b = 0;
    cin >> a >> b;
    long long r = pow(a * b, 1 / 3.) + EPS;
    long long root = r;
    if (root * root * root == a * b && a % root == 0 && b % root == 0) {
      cout << "YES\n";
    } else {
      cout << "NO\n";
    }
  }
  return 0;
}
