#include <bits/stdc++.h>
using namespace std;
long long pwr(long long base, long long p, long long mod = (1000000007LL)) {
  long long ans = 1;
  while (p) {
    if (p & 1) ans = (ans * base) % mod;
    base = (base * base) % mod;
    p /= 2;
  }
  return ans;
}
long long gcd(long long a, long long b) {
  if (b == 0) return a;
  return gcd(b, a % b);
}
const int N = 1000002;
int sieve[N], prime_facs[N];
int main() {
  for (int i = 2; i < N; i++)
    if (sieve[i] == 0) {
      for (int j = i; j < N; j += i) {
        sieve[j] = 1;
        if (prime_facs[j] == 0) prime_facs[j] = i;
      }
    }
  int t;
  scanf("%d", &t);
  while (t--) {
    long long a, b;
    scanf("%lld%lld", &a, &b);
    long long prod = a * b;
    long long lo = 1, hi = 1000 * 1000 + 1, ans = 0;
    ans = cbrt(prod);
    while (ans * ans * ans < prod) ans++;
    while (ans * ans * ans > prod) ans--;
    if (ans * ans * ans != prod) {
      printf("No\n");
      continue;
    }
    bool bad = false;
    while (ans != 1) {
      int p = prime_facs[ans];
      int c1 = 0, c2 = 0, c3 = 0;
      while (a % p == 0) {
        a /= p;
        c1++;
      }
      while (b % p == 0) {
        b /= p;
        c2++;
      }
      while (ans % p == 0) {
        ans /= p;
        c3++;
      }
      if ((2 * c1 - c2) % 3 != 0 || (2 * c1 < c2)) bad = true;
      swap(c1, c2);
      if ((2 * c1 - c2) % 3 != 0 || (2 * c1 < c2)) bad = true;
      if (bad) break;
    }
    if (!bad)
      printf("Yes\n");
    else
      printf("No\n");
  }
  return 0;
}
