#include <bits/stdc++.h>
using namespace std;
long long bs(long long l, long long r, long long val) {
  if (l > r) return -1;
  if (l == r) {
    long long n = l;
    if ((n * n * n) == val)
      return l;
    else
      return -1;
  }
  long long mid = (l + r) / 2;
  long long n = mid;
  long long val2 = n * n * n;
  if (val2 == val) return mid;
  if (val2 > val)
    return bs(l, mid - 1, val);
  else
    return bs(mid + 1, r, val);
}
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n;
  long long val;
  cin >> n;
  while (n--) {
    int f = 0;
    long long first, second;
    cin >> first >> second;
    long long gcd;
    long long lcm;
    lcm = (first * second);
    long long l = 1, r = 1e6;
    long long val = bs(1, 1e6, lcm);
    if (val != -1) {
      if (first % val == 0 && second % val == 0)
        cout << "Yes";
      else {
        cout << "No";
      }
    } else {
      cout << "No";
    }
    cout << '\n';
  }
  return 0;
}
