#include <bits/stdc++.h>
using namespace std;
const long long maxn = 1e6 + 20;
const long long INF = 0x3f3f3f3f;
int main() {
  long long n, a, b;
  scanf("%lld", &n);
  while (n--) {
    scanf("%lld %lld", &a, &b);
    long long c = a * b;
    long long L = 1, R = 1000020, mid;
    while (R - L > 3) {
      mid = L + R >> 1;
      if (mid * mid * mid >= c)
        R = mid + 1;
      else
        L = mid - 1;
    }
    long long i, flag = 1;
    for (i = L; i <= R && i * i * i < c; i++)
      ;
    if (i * i * i == c) {
      if (a % i != 0 || b % i != 0) {
        flag = 0;
        printf("NO\n");
        continue;
      }
      puts("Yes");
    } else
      puts("No");
  }
  return 0;
}
