#include <bits/stdc++.h>
using namespace std;
const int Hash = 131;
const int maxn = 1e5 + 5;
const int maxm = 100000 + 5;
const int mod = 1e9 + 7;
const int inf = 0x3f3f3f3f;
const long long INF = 0x3f3f3f3f3f3f3f3f;
const double eps = 1e-7;
const double pi = acos(-1);
inline long long lowbit(long long x) { return x & (-x); }
long long gcd(long long a, long long b) { return b ? gcd(b, a % b) : a; }
void ex_gcd(long long a, long long b, long long &d, long long &x,
            long long &y) {
  if (!b) {
    d = a, x = 1, y = 0;
  } else {
    ex_gcd(b, a % b, d, y, x);
    y -= x * (a / b);
  }
}
inline long long qpow(long long a, long long b, long long MOD = mod) {
  long long res = 1;
  a %= MOD;
  while (b > 0) {
    if (b & 1) res = res * a % MOD;
    a = a * a % MOD;
    b >>= 1;
  }
  return res % MOD;
}
inline long long qmul(long long a, long long b, long long MOD = mod) {
  return (a * b - (long long)((long double)a / MOD * b) * MOD + MOD) % MOD;
}
inline long long inv(long long x, long long p) { return qpow(x, p - 2, p); }
inline long long jos(long long n, long long k, long long s = 1) {
  long long res = 0;
  for (int i = 1; i < n + 1; ++i) res = (res + k) % i;
  return (res + s) % n;
}
double f(double x) { return x; }
inline double sim(double l, double r) {
  return (f(l) + 4. * f((l + r) / 2.) + f(r)) * (r - l) / 6.;
}
double asr(double l, double r, double ans, double eps) {
  double m = l + (r - l) / 2., L = sim(l, m), R = sim(m, r);
  return fabs(L + R - ans) <= 15. * eps
             ? L + R + (L + R - ans) / 15.
             : asr(l, m, L, eps / 2) + asr(m, r, R, eps / 2);
}
double asr(double l, double r, double eps) { return asr(l, r, sim(l, r), eps); }
namespace FastIO {
char buf[1 << 21], buf2[1 << 21], a[20], *p1 = buf, *p2 = buf, end = '\n';
int p, p3 = -1;
void read() {}
void write() {}
inline int getc() {
  return p1 == p2 && (p2 = (p1 = buf) + fread(buf, 1, 1 << 21, stdin), p1 == p2)
             ? EOF
             : *p1++;
}
inline void flush() { fwrite(buf2, 1, p3 + 1, stdout), p3 = -1; }
template <typename T, typename... T2>
inline void read(T &x, T2 &...oth) {
  int f = 0;
  x = 0;
  char ch = getc();
  while (!isdigit(ch)) {
    if (ch == '-') f = 1;
    ch = getc();
  }
  while (isdigit(ch)) {
    x = x * 10 + ch - '0';
    ch = getc();
  }
  x = f ? -x : x;
  read(oth...);
}
template <typename T, typename... T2>
inline void write(T x, T2... oth) {
  if (p3 > 1 << 20) flush();
  if (x < 0) buf2[++p3] = '-', x = -x;
  do {
    a[++p] = x % 10 + '0';
  } while (x /= 10);
  do {
    buf2[++p3] = a[p];
  } while (--p);
  buf2[++p3] = end;
  write(oth...);
}
}  // namespace FastIO
using namespace FastIO;
int n, m;
long long A, B, x, QwQ;
inline void solve() {
  read(A, B);
  x = round(pow(A * B, 1.0 / 3));
  puts(!(A % x) && !(B % x) && (x * x * x) == A * B ? "Yes" : "No");
}
int main() {
  for (read(QwQ); QwQ; QwQ--) solve();
  return 0;
}
