#include <bits/stdc++.h>
using namespace std;
long long MOD = 1e9 + 7;
long long MAX = 1e17;
int main() {
  int n;
  cin >> n;
  long long a, b;
  for (int i = 0; i < n; ++i) {
    scanf("%I64d%I64d", &a, &b);
    long long x = a * b;
    if (a == 1 and b == 1) {
      cout << "Yes"
           << "\n";
      ;
      continue;
    }
    long long y = cbrtl(x);
    if (y * (y * y) != x) {
      cout << "No"
           << "\n";
      ;
      continue;
    }
    if (a % y == 0 and b % y == 0) {
      cout << "Yes"
           << "\n";
      ;
    } else {
      cout << "No"
           << "\n";
      ;
    }
  }
  return 0;
}
