#include <bits/stdc++.h>
using namespace std;
const int maxn = 1000005;
const int base = 1e9 + 7;
int croot(long long int x);
int main(void) {
  int n;
  long long int a, b;
  while (cin >> n) {
    long long int x;
    for (int j = 1; j <= n; j++) {
      scanf("%I64d %I64d", &a, &b);
      x = croot(a * b);
      if (x * x * x == a * b && a % x == 0 && b % x == 0) {
        printf("Yes\n");
      } else {
        printf("No\n");
      }
    }
  }
  return 0;
}
int croot(long long int x) {
  int l = 0, r = maxn;
  while (l != r) {
    long long int m = (l + r + 1) / 2;
    if (m * m * m > x) {
      r = m - 1;
    } else {
      l = m;
    }
  }
  return l;
}
