#include <bits/stdc++.h>
using namespace std;
long long gcd(long long a, long long b) { return (b == 0) ? a : gcd(b, a % b); }
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  long long n;
  cin >> n;
  for (long long f = 1; f <= n; ++f) {
    long long a, b, x;
    cin >> a >> b;
    x = gcd(a, b);
    a /= x;
    b /= x;
    if (x % a == 0 && x % b == 0) {
      x /= a;
      x /= b;
      if ((x == 1) || round(cbrt(x)) * round(cbrt(x)) * round(cbrt(x)) == x) {
        cout << "Yes" << '\n';
        continue;
      } else {
        cout << "No" << '\n';
      }
    } else {
      cout << "No" << '\n';
      continue;
    }
  }
  return 0;
}
