#include <bits/stdc++.h>
using namespace std;
long long cubic_root(long long x) {
  long long l = 0, r = 1000005;
  while (l != r) {
    long long m = (l + r + 1) / 2;
    if (m * m * m > x)
      r = m - 1;
    else
      l = m;
  }
  return l;
}
int main() {
  long long n;
  scanf("%lld", &n);
  while (n--) {
    long long a, b;
    scanf("%lld %lld", &a, &b);
    long long t = a * b;
    long long c = cubic_root(t);
    if (c * c * c != t) {
      printf("NO\n");
    } else if (a % c == 0 && b % c == 0) {
      printf("YES\n");
    } else
      printf("NO\n");
  }
  return 0;
}
