#include <bits/stdc++.h>
using namespace std;
long long cube(long long c) {
  long long lo = 1, hi = 1e6;
  while (lo < hi) {
    long long mi = (lo + hi) >> 1;
    long long val = mi * mi * mi;
    if (val > c)
      hi = mi - 1;
    else if (val < c)
      lo = mi + 1;
    else
      return mi;
  }
  if (lo * lo * lo == c) return lo;
  return -1;
}
int main() {
  ios_base::sync_with_stdio(0);
  ;
  cin.tie(NULL);
  long long n;
  cin >> n;
  for (long long i = 1; i <= n; i++) {
    long long a, b;
    cin >> a >> b;
    long long c = a * b, ans = cube(c);
    if (ans != -1) {
      if (a % ans == 0 and b % ans == 0) {
        cout << "Yes"
             << "\n";
      } else
        cout << "No"
             << "\n";
    } else
      cout << "No"
           << "\n";
  }
}
