#include <bits/stdc++.h>
using namespace std;
long long a, b;
inline bool check(long long x) {
  long long t = (long long)cbrt(x);
  return t * t * t == x;
}
void solve() {
  scanf("%lld%lld", &a, &b);
  long long a2 = 1ll * a * a;
  long long b2 = 1ll * b * b;
  long long ab = a2 / b;
  long long ba = b2 / a;
  if (ab * b != a2 || ba * a != b2) {
    cout << "No\n";
    return;
  }
  if (!check(ab) || !check(ba)) {
    cout << "No\n";
    return;
  }
  cout << "Yes\n";
}
int main() {
  int t;
  cin >> t;
  for (int i = 0; i < t; i++) solve();
  return 0;
}
