#include <bits/stdc++.h>
using namespace std;
long long a, b, c, x;
int n;
long long s3(long long x) {
  long long l = 1, r = 1e6, res = -1;
  while (l <= r) {
    long long mid = (l + r) >> 1, val = mid * mid * mid;
    if (val == x) return mid;
    if (val < x) l = mid + 1;
    if (val > x) r = mid - 1;
  }
  return -1;
}
int main() {
  scanf("%d", &n);
  while (n--) {
    scanf("%I64d%I64d", &a, &b);
    c = a * b;
    x = s3(c);
    if (x != -1 && a % x == 0 && b % x == 0)
      puts("Yes");
    else
      puts("No");
  }
  return 0;
}
