#include <bits/stdc++.h>
using namespace std;
const int N = (int)3e5 + 123, inf = (int)1e9 + 123, mod = (int)1e9 + 7;
long long a, b;
const long long INF = (long long)1e18 + 123;
int Power_3(long long x) {
  int L = 0, R = 1e6 + 1, ans = -1;
  while (L <= R) {
    int mid = (L + R) >> 1;
    if (mid * 1LL * mid * 1LL * mid > x) {
      R = mid - 1;
    } else {
      L = mid + 1;
      ans = mid;
    }
  }
  return ans;
}
void Solve() {
  cin >> a >> b;
  int x = Power_3(a * b);
  if (x * 1LL * x * 1LL * x == a * b && a % x == 0 && b % x == 0) {
    cout << "Yes\n";
    return;
  }
  cout << "No\n";
  return;
}
int main() {
  cin.tie(0);
  cout.tie(0);
  ios_base::sync_with_stdio(NULL);
  int t = 1;
  cin >> t;
  while (t--) {
    Solve();
  }
  return 0;
}
