#include <bits/stdc++.h>
using namespace std;
const int inf = 1e9 + 9;
const int mod = 1e9 + 7;
int n, m, k;
const int MX = 1000010;
int sito[MX + 5];
vector<int> primes;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  int t;
  cin >> t;
  while (t--) {
    long long int a, b;
    cin >> a >> b;
    long long int ilo = a * b;
    long long int x = 1, y = MX;
    while (x < y) {
      long long int sr = (x + y) / 2;
      if (sr * sr * sr < ilo)
        x = ++sr;
      else
        y = sr;
    }
    bool odp = 1;
    if (x * x * x != ilo)
      odp = 0;
    else {
      if (a % x != 0) odp = 0;
      if (b % x != 0) odp = 0;
    }
    if (odp)
      cout << "Yes\n";
    else
      cout << "No\n";
  }
}
