#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  long long n, a, b;
  cin >> n;
  while (n--) {
    cin >> a >> b;
    long long x = (long long)cbrt(a * b);
    long long v = a / x, u = b / x;
    if (v * v * u == a && v * u * u == b)
      cout << "Yes\n";
    else
      cout << "No\n";
  }
  return 0;
}
