#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  long long z, c, d;
  int n, a, b;
  cin >> n;
  while (n--) {
    cin >> a >> b;
    z = cbrt((long long)a * b);
    c = a / z;
    d = b / z;
    if (c * c * d == a && d * d * c == b)
      cout << "YES\n";
    else
      cout << "NO\n";
  }
  return 0;
}
