#include <bits/stdc++.h>
using namespace std;
map<long long int, int> ma;
int main() {
  int n, x, y;
  scanf("%d", &n);
  for (int i = 1; i <= 1e6; i++) ma[1ll * i * i * i] = 1;
  while (n--) {
    scanf("%d %d", &x, &y);
    if (ma.find(1ll * x * y) == ma.end())
      printf("No\n");
    else if ((1ll * x * x) % y || (1ll * y * y) % x)
      printf("No\n");
    else
      printf("Yes\n");
  }
}
