#include <bits/stdc++.h>
using namespace std;
const int Maxn = 1e6 + 5;
long long check(long long x) {
  long long l = 0, r = Maxn;
  long long m;
  while (l < r) {
    m = (l + r + 1) / 2;
    if (m * m * m > x)
      r = m - 1;
    else
      l = m;
  }
  return l;
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  int n;
  cin >> n;
  while (n--) {
    long long a, b;
    cin >> a >> b;
    long long x = check(a * b);
    if (x * x * x != a * b)
      printf("No\n");
    else if (a % x == 0 && b % x == 0)
      printf("Yes\n");
    else
      printf("No\n");
  }
  return 0;
}
