#include <bits/stdc++.h>
using namespace std;
const int INF = 0x3f3f3f3f, maxn = 1000001;
long long t[maxn];
void init() {
  for (int i = 0; i <= 1000000; i++) t[i] = (long long)i * i * i;
}
int main() {
  init();
  int n, a, b;
  scanf("%d", &n);
  while (n--) {
    scanf("%d%d", &a, &b);
    long long c = (long long)a * b;
    int pos = lower_bound(t, t + maxn, c) - t;
    if ((long long)pos * pos * pos == c && a % pos == 0 && b % pos == 0)
      printf("Yes\n");
    else
      printf("No\n");
  }
  return 0;
}
