#include <bits/stdc++.h>
using namespace std;
long long int gcd(long long int a, long long int b) {
  if (b == 0) return a;
  return gcd(b, a % b);
}
long long int cb(long long int x) {
  long long int l = 0, r = 1e6, mx = 0;
  while (l <= r) {
    long long int m = (l + r) / 2;
    if (m * m * m <= x) {
      l = m + 1;
      mx = m;
    } else
      r = m - 1;
  }
  return mx;
}
void JAISHREERAM() {
  long long int a, b, x, y;
  cin >> a >> b;
  x = cb(a * b);
  if (x * x * x != a * b || a % x || b % x)
    cout << "No\n";
  else
    cout << "Yes\n";
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  ;
  int T = 1;
  cin >> T;
  for (int t = 1; t <= T; t++) {
    JAISHREERAM();
  }
  return 0;
}
