#include <bits/stdc++.h>
using namespace std;
long long int check[32000];
long long int prime[10000];
long long int cnt = 0;
void shieve() {
  for (int i = 3; i <= 180; i += 2) {
    if (!check[i]) {
      for (int j = i * i; j <= 32000; j += i) check[j] = 1;
    }
  }
  prime[0] = 2;
  int j = 1;
  for (int i = 3; i <= 32000; i += 2) {
    if (!check[i]) {
      prime[j++] = i;
    }
  }
}
int main() {
  long long int n, cnt1, cnt2;
  scanf("%lld", &n);
  shieve();
  for (long long int i = 0; i < n; i++) {
    long long int a, b;
    cnt = 0;
    scanf("%lld%lld", &a, &b);
    long double m = a * b;
    long long int r = cbrt(m);
    long long int j, k = 0;
    long long int flag = 0;
    for (j = prime[k]; j * j <= r; j = prime[++k]) {
      if (r % j == 0) {
        cnt1 = cnt2 = 0;
        while (a % j == 0) {
          cnt1++;
          a /= j;
        }
        while (b % j == 0) {
          cnt2++;
          b /= j;
        }
        while (r % j == 0) r /= j;
        if ((cnt1 + cnt2) % 3 != 0 || max(cnt1, cnt2) > min(cnt1, cnt2) * 2) {
          flag = 1;
        }
      }
    }
    if (r > 1) {
      j = r;
      cnt1 = cnt2 = 0;
      while (a % j == 0) {
        cnt1++;
        a /= j;
      }
      while (b % j == 0) {
        cnt2++;
        b /= j;
      }
      if ((cnt1 + cnt2) % 3 != 0 || max(cnt1, cnt2) > min(cnt1, cnt2) * 2) {
        flag = 1;
      }
    }
    if (a > 1 || b > 1) flag = 1;
    if (flag == 0)
      printf("Yes\n");
    else
      printf("No\n");
  }
  return 0;
}
