#include <bits/stdc++.h>
using namespace std;
long long GCD(long long x, long long y) {
  while (y != 0) {
    long long t = x % y;
    x = y;
    y = t;
  }
  return x;
}
long long n, a, b;
long long cs;
bool calc() {
  scanf("%lld %lld", &a, &b);
  long long g = GCD(a, b);
  long long p = a / g;
  long long q = b / g;
  long long pq = p * q;
  bool ret = (g % pq == 0);
  if (ret) {
    long long r = g / pq;
    long long i = 1;
    while (i * i * i < r) {
      i++;
    }
    if (i * i * i == r) return true;
  }
  return false;
}
int main() {
  scanf("%lld", &n);
  while (cs < n) {
    cs++;
    bool ans = calc();
    if (ans)
      printf("Yes\n");
    else
      printf("No\n");
  }
  return 0;
}
