#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  long long a, b, c, d, e, f, i, j, k, n;
  cin >> n;
  while (n--) {
    cin >> a >> b;
    c = a * b;
    d = (long long)cbrt(c);
    f = 0;
    for (i = d - 1; i <= d + 1; i++) {
      if ((i * i * i) == c) {
        f = 1;
        break;
      }
    }
    if (f == 0) {
      cout << "No\n";
      continue;
    }
    d = i;
    if (a % d != 0 || b % d != 0) {
      cout << "No\n";
      continue;
    }
    cout << "Yes\n";
  }
  return 0;
}
