#include <bits/stdc++.h>
using namespace std;
const int maxn = 1000005;
unsigned long long f[maxn];
void init() {
  for (int i = 0; i < maxn; i++)
    f[i] =
        (unsigned long long)i * (unsigned long long)i * (unsigned long long)i;
}
int main() {
  int n;
  scanf("%d", &n);
  init();
  while (n--) {
    unsigned long long x, y;
    scanf("%I64d%I64d", &x, &y);
    unsigned long long cnt = x * y;
    int pos = lower_bound(f, f + maxn, cnt) - f;
    if (f[pos] == cnt && x % pos == 0 && y % pos == 0)
      printf("Yes\n");
    else
      printf("No\n");
  }
  return 0;
}
