#include <bits/stdc++.h>
using namespace std;
const double eps = 1e-6;
const int inf = 0x3f3f3f3f;
int main() {
  int n;
  long long a, b;
  scanf("%d", &n);
  for (int _ = 1; _ <= n; ++_) {
    scanf("%I64d %I64d", &a, &b);
    long long x = cbrt(1.0 * a * b);
    long long c = a / x, d = b / x;
    if (c * d * c == a && c * d * d == b)
      puts("Yes");
    else
      puts("No");
  }
  return 0;
}
