#include <bits/stdc++.h>
using namespace std;
struct _ {
  ios_base::Init i;
  _() { ios_base::sync_with_stdio(false), cin.tie(NULL), cout.tie(NULL); }
} _;
template <class c>
struct rge {
  c b, e;
};
template <class c>
rge<c> range(c i, c j) {
  return rge<c>{i, j};
}
template <class c>
auto dud(c* x) -> decltype(cerr << *x, 0);
template <class c>
char dud(...);
struct debug {
  template <class c>
  debug& operator<<(const c&) {
    return *this;
  }
};
const int MOD = 1e9 + 7;
class MainClass {
 public:
  long long is_cube(long long n) {
    long long cb = cbrt(n);
    if (cb * cb * cb == n) return cb;
    return 0;
  }
  void solve() {
    long long a, b;
    cin >> a >> b;
    long long cb = is_cube(a * b);
    if (!cb) {
      cout << "No";
      return;
    }
    long long aa = a / cb;
    long long bb = b / cb;
    if (aa * aa * bb == a and bb * bb * aa == b)
      cout << "Yes";
    else
      cout << "No";
    return;
  }
};
int main() {
  int test = 1;
  cin >> test;
  for (int tst = 1; tst <= test; ++tst) {
    MainClass Ausmosian;
    Ausmosian.solve();
    cout << "\n";
  }
  return 0;
}
