#include <bits/stdc++.h>
using namespace std;
template <typename T>
inline void read(T &x) {
  char c;
  bool nega = 0;
  while ((!isdigit(c = getchar())) && (c != '-'))
    ;
  if (c == '-') {
    nega = 1;
    c = getchar();
  }
  x = c - 48;
  while (isdigit(c = getchar())) x = x * 10 + c - 48;
  if (nega) x = -x;
}
template <typename T>
inline void writep(T x) {
  if (x > 9) writep(x / 10);
  putchar(x % 10 + 48);
}
template <typename T>
inline void write(T x) {
  if (x < 0) {
    putchar('-');
    x = -x;
  }
  writep(x);
}
template <typename T>
inline void writeln(T x) {
  write(x);
  putchar('\n');
}
int n;
int pri[1000001];
vector<int> v;
long long a, b;
bool solve() {
  pair<int, int> old = make_pair(a, b);
  long long s = a * b;
  if (s == 1) return 1;
  long long k = exp(log(s) / 3);
  while (k * k * k > s) k--;
  while (k * k * k < s) k++;
  if (k * k * k == s) {
    while (k > 1) {
      int i = pri[k];
      int sum = 0;
      while (k % i == 0) {
        k /= i;
        sum++;
      }
      int m = 0, n = 0;
      while (a % i == 0) {
        a /= i;
        m++;
      }
      while (b % i == 0) {
        b /= i;
        n++;
      }
      if (m < sum || n < sum) return 0;
    }
    return 1;
  } else
    return 0;
}
int main() {
  read(n);
  for (int i = 2; i <= 1000000; i++)
    if (!pri[i]) {
      for (int j = i; j <= 1000000; j += i) pri[j] = i;
    }
  while (n--) {
    read(a);
    read(b);
    puts(solve() ? "Yes" : "No");
  }
}
