#include <bits/stdc++.h>
#pragma comment(linker, "/STACK:102400000,102400000")
using namespace std;
const int maxn = 500000 + 5;
const int INF = 0x3f3f3f3f;
const int P = 1000000007;
const double PI = acos(-1.0);
template <typename T>
inline T read(T &x) {
  x = 0;
  int _f = 0;
  char ch = getchar();
  while (ch < '0' || ch > '9') _f |= (ch == '-'), ch = getchar();
  while (ch >= '0' && ch <= '9') x = x * 10 + ch - '0', ch = getchar();
  return x = _f ? -x : x;
}
template <class T1, class T2>
inline void gmax(T1 &a, T2 b) {
  if (b > a) a = b;
}
template <class T1, class T2>
inline void gmin(T1 &a, T2 b) {
  if (b < a) a = b;
}
void up(int &x, int y) {
  x += y;
  if (x >= P) x -= P;
}
int n;
long long A, B;
int main() {
  for (read(n); n--;) {
    read(A), read(B);
    long long ab = cbrt((long double)A * B);
    long long a = A / ab;
    long long b = B / ab;
    puts(a * a * b == A && a * b * b == B ? "Yes" : "No");
  }
  return 0;
}
