#include <bits/stdc++.h>
long long int M = 1e9 + 7;
void MultL(long long int &a, long long int b) { a = (a * b) % M; }
void AddL(long long int &a, long long int b) { a = (a + (b + M)) % M; }
long long int Mult(long long int a, long long int b) { return (a * b) % M; }
long long int Add(long long int a, long long int b) {
  return (a + (b + M)) % M;
}
using namespace std;
int main() {
  std::ios::sync_with_stdio(false);
  int n;
  cin >> n;
  for (int i = 0; i < n; ++i) {
    long long int a, b;
    cin >> a >> b;
    long long int m = a * b;
    long long int p = (long long int)pow(static_cast<long double>(m), 1 / 3.0);
    while (p * p * p < m) ++p;
    if (p * p * p != m) {
      cout << "No" << endl;
      continue;
    }
    a /= p;
    b /= p;
    if (a * b == p)
      cout << "Yes" << endl;
    else
      cout << "No" << endl;
  }
  return 0;
}
