#include <bits/stdc++.h>
using namespace std;
const int maxn = 1e5 + 9;
long long gcd(long long a, long long b) {
  long long c;
  while (b) {
    c = a % b;
    a = b;
    b = c;
  }
  return a;
}
int main() {
  int t;
  ios::sync_with_stdio(0);
  cin >> t;
  while (t--) {
    long long a, b;
    cin >> a >> b;
    long long tmp = a * b;
    tmp = pow(tmp, 1.0 / 3.0);
    if (tmp * tmp * tmp != a * b) {
      tmp++;
    }
    if (tmp * tmp * tmp != a * b) {
      cout << "No" << endl;
      continue;
    }
    if (tmp > a || tmp > b) {
      cout << "No" << endl;
      continue;
    }
    if (gcd(tmp, a) != tmp || gcd(tmp, b) != tmp) {
      cout << "No" << endl;
      continue;
    }
    cout << "Yes" << endl;
  }
}
