#include <bits/stdc++.h>
using namespace std;
const long long int inf = 1e9 + 7;
const long long int modc = 998244353;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);
  cout.tie(nullptr);
  int n;
  cin >> n;
  while (n--) {
    long long int a, b;
    cin >> a >> b;
    long long int prod = a * b, cb = round(cbrt(prod));
    if (cb * cb * cb == prod && a % cb == 0 && b % cb == 0)
      cout << "Yes\n";
    else
      cout << "No\n";
  }
  return 0;
}
