#include <bits/stdc++.h>
using namespace std;
long long int mod = 1000000007;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  unsigned long long int t, a, b, x, y, z;
  t = 1;
  cin >> t;
  while (t--) {
    cin >> a >> b;
    x = a * b;
    y = round(cbrt(x));
    z = y * y * y;
    if ((z == a * b) && (a % y == 0) && (b % y == 0)) {
      cout << "YES\n";
    } else {
      cout << "NO\n";
    }
  }
  return 0;
}
