#include <bits/stdc++.h>
const long double eps = 0.00000001;
const long long MOD = 1e9 + 7;
using namespace std;
char yes[] = {"Yes"};
char no[] = {"No"};
int main() {
  fflush(stdin);
  cout << fixed, cout.precision(18);
  ios_base::sync_with_stdio(false);
  long long n, i, j;
  cin >> n;
  for (i = 0; i < n; ++i) {
    long long a, b;
    cin >> a >> b;
    long long c = a * 1ll * b;
    long long d = (long long)cbrt((long double)c);
    long long cura = a / d;
    long long curb = b / d;
    if (cura * cura * curb == a && curb * curb * cura == b)
      printf("%s\n", yes);
    else
      printf("%s\n", no);
  }
}
