#include <bits/stdc++.h>
using namespace std;
long long cubeRoot(long long n) {
  long long l = 0, r = 1001010, m;
  while (l != r) {
    m = (l + r + 1) / 2;
    if (m * m * m > n) {
      r = m - 1;
    } else {
      l = m;
    }
  }
  return l;
}
int main() {
  long long c, a, b, n, i, j, k, flag = 0, x, sum = 0, sum2 = 0, sr;
  cin >> n;
  for (i = 0; i < n; i++) {
    scanf("%I64d %I64d", &a, &b);
    c = cubeRoot(a * b);
    if ((c * c * c) == (a * b) && a % c == 0 && b % c == 0) {
      printf("Yes\n");
    } else {
      printf("No\n");
    }
  }
  return 0;
}
