#include <bits/stdc++.h>
using namespace std;
int T, x, y;
int main() {
  scanf("%d", &T);
  while (T--) {
    scanf("%d%d", &x, &y);
    double p = pow((long long)x * y, (double)1.0 / 3);
    int P = round(p);
    if (fabs(P - p) <= 1e-3 && !(x % P) && !(y % P))
      puts("Yes");
    else
      puts("No");
  }
  return 0;
}
