#include <bits/stdc++.h>
using namespace std;
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  int t;
  cin >> t;
  while (t-- > 0) {
    long long a, b;
    cin >> a >> b;
    string res = "No\n";
    long long raiz = cbrt(a * b);
    for (long long i = max(1LL, raiz - 2); i < raiz + 2; ++i) {
      if (a * b == i * i * i && a % i == 0 && b % i == 0) {
        res = "Yes\n";
        break;
      }
    }
    cout << res;
  }
  return 0;
}
