#include <bits/stdc++.h>
using namespace std;
namespace IO {
static char buf[1 << 20], *fs, *ft;
inline char gc() {
  if (fs == ft) {
    ft = (fs = buf) + fread(buf, 1, 1 << 20, stdin);
    if (fs == ft) return EOF;
  }
  return *fs++;
}
inline int read() {
  long long x = 0, f = 1;
  char s = getchar();
  while (s < '0' || s > '9') {
    if (s == '-') f = -f;
    s = getchar();
  }
  while (s >= '0' && s <= '9') {
    x = x * 10 + s - '0';
    s = getchar();
  }
  return x * f;
}
}  // namespace IO
using IO ::read;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  long long t;
  cin >> t;
  while (t--) {
    long long a, b;
    cin >> a >> b;
    long long x = cbrtl(a * b);
    if (x * x * x == a * b and a % x == 0 and b % x == 0) {
      cout << "Yes"
           << "\n";
    } else {
      cout << "No"
           << "\n";
    }
  }
  return 0;
}
