#include <bits/stdc++.h>
using namespace std;
const double O = 1e-10;
double abss(double x) {
  if (x >= 0) return x;
  return -x;
}
int isz(double x) {
  if (abss(x - round(x)) < O) {
    return 1;
  }
  return 0;
}
long long a, b;
int main() {
  int n;
  scanf("%d", &n);
  while (n--) {
    scanf("%I64d%I64d", &a, &b);
    int F = 0;
    long long ab = (long long)a * b;
    long long ps = round(pow((double)ab, (double)1.0 / 3));
    {
      if ((a % ps == 0) && (b % ps == 0) && (a / ps * b / ps == ps)) {
        F = 1;
      }
      ps++;
      if ((a % ps == 0) && (b % ps == 0) && (a / ps * b / ps == ps)) {
        F = 1;
      }
      ps--;
      ps--;
      if (ps > 0 && (a % ps == 0) && (b % ps == 0) && (a / ps * b / ps == ps)) {
        F = 1;
      }
    }
    if (F) {
      printf("Yes\n");
    } else {
      printf("No\n");
    }
  }
  return 0;
}
