#include <bits/stdc++.h>
using namespace std;
const double PI =
    3.14159265358979323846264338327950288419716939937510582097494459230;
int32_t main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  long long t;
  cin >> t;
  vector<long long> v((1e6) + 15);
  for (long long i = 0; i < (1000015); i++) v[i] = i * i * i;
  while (t--) {
    long long a, b;
    cin >> a >> b;
    long long c = a * b;
    long long c1 = lower_bound(v.begin(), v.end(), c) - v.begin();
    if (pow(c1, 3) != c) {
      cout << "No\n";
      continue;
    }
    if (a % c1 == 0 and b % c1 == 0)
      cout << "Yes\n";
    else
      cout << "No\n";
  }
}
