#include <bits/stdc++.h>
using namespace std;
long double cuberoot(long double a) {
  long double lo = 0, hi = 1000000000, mid;
  int T = 200;
  while (T--) {
    mid = (lo + hi) / 2;
    if (mid * mid * mid > a)
      hi = mid;
    else if (mid * mid * mid < a)
      lo = mid;
  }
  return mid;
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  int T;
  cin >> T;
  while (T--) {
    long double ab;
    long long x, y, a, b;
    cin >> x >> y;
    ab = cuberoot(x * y);
    a = (long long)((long double)y) / ab;
    b = (long long)((long double)x) / ab;
    if (a * b * b == x && a * a * b == y)
      cout << "YES\n";
    else
      cout << "NO\n";
  }
}
