#include <bits/stdc++.h>
#pragma GCC optimize("Ofast")
#pragma GCC target("avx,avx2,fma")
#pragma GCC optimization("unroll-loops")
using namespace std;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
void naive(int x, int y) {
  if (x == y) {
    cout << "Yes\n";
    return;
  }
  for (int i = 2; i * i <= x; i++) {
    while (x % i == 0) {
      if (y % (i * i) == 0) {
        y /= i * i;
        x /= i;
      } else if (x % (i * i) == 0 && y % i == 0) {
        x /= i * i;
        y /= i;
      } else {
        cout << "No\n";
        return;
      }
    }
  }
  if (x == y * y || x * x == y)
    cout << "Yes\n";
  else
    cout << "No\n";
}
void fast(long long x, long long y) {
  long long p = x * y;
  long long l = 1, r = 1e6 + 42;
  while (r - l > 1) {
    long long m = ((r + l) >> 1);
    if (m * m * m > p)
      r = m;
    else
      l = m;
  }
  if (l * l * l == p && x % l == 0 && y % l == 0)
    cout << "Yes\n";
  else if (r * r * r == p && x % r == 0 && y % r == 0)
    cout << "Yes\n";
  else
    cout << "No\n";
}
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  int n = 0;
  cin >> n;
  while (n--) {
    long long a, b;
    cin >> a >> b;
    if (a > b) swap(a, b);
    fast(a, b);
  }
  return 0;
}
