#include <bits/stdc++.h>
using namespace std;
long long a, b, c, flag;
bool find(long long x, long long y) {
  long long mid, l = 1, r = 1e6;
  while (l <= r) {
    mid = (l + r) / 2;
    if (mid * mid * mid == x * y) {
      return true;
    }
    if (mid * mid * mid < x * y) {
      l = mid + 1;
    } else {
      r = mid - 1;
    }
  }
  return false;
}
int main() {
  long long n;
  scanf("%lld", &n);
  while (n--) {
    flag = 0;
    scanf("%lld%lld", &a, &b);
    if (a * a % b == 0 && b * b % a == 0 && find(a, b)) {
      printf("Yes\n");
    } else {
      printf("No\n");
    }
  }
  return 0;
}
