#include <bits/stdc++.h>
using namespace std;
const double eps = 1e-4;
int main() {
  int n;
  scanf("%d", &n);
  for (int i = 0; i < n; i++) {
    long long a, b;
    scanf("%lld%lld", &a, &b);
    double yz = pow((double)a * b, 1.0 / 3);
    long long tmp = (long long)(yz + 0.5);
    if (a % tmp == 0 && b % tmp == 0 && (a * b) % tmp == 0 &&
        ((a / tmp) * (b / tmp) == tmp)) {
      printf("Yes\n");
    } else {
      printf("No\n");
    }
  }
  return 0;
}
