#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  int n, m, r, i, ii, t;
  cin >> n;
  for (ii = 0; ii < n; ii++) {
    long long a, b, j, l;
    cin >> a >> b;
    l = a * b;
    j = round(cbrt(l));
    if (j * j * j == l) {
      if (a % j == 0 && b % j == 0)
        cout << "Yes\n";
      else
        cout << "No\n";
    } else {
      cout << "No\n";
    }
  }
}
