#include <bits/stdc++.h>
using namespace std;
long long int __gcd(long long int a, long long int b) {
  return (a % b) ? __gcd(b, a % b) : b;
}
bool prime(long long int k) {
  for (long long int i = 2; i * i <= k; i++)
    if (k % i == 0) {
      return false;
    }
  return true;
}
void pdash(int n = 1) {
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < 30; j++) {
      cout << "-";
    }
    cout << "\n";
  }
}
long long int cube_root(long long int a) {
  long long int r = 1000000, l = 1;
  long long int mid;
  while (r - l > 1) {
    mid = (r + l) >> 1;
    if (mid * mid * mid == a) {
      return mid;
    } else if (mid * mid * mid > a) {
      r = mid;
    } else
      l = mid;
  }
  if (l * l * l == a) return l;
  if (r * r * r == a) return r;
  return -1;
}
void solve() {
  int n;
  cin >> n;
  long long int a, b;
  while (n--) {
    cin >> a >> b;
    long long int c = cube_root(a * b);
    if (c != -1 && a % c == 0 && b % c == 0) {
      cout << "Yes\n";
    } else
      cout << "No\n";
  }
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  int t = 1;
  while (t--) solve();
}
