#include <bits/stdc++.h>
using namespace std;
long long root_search(int64_t n) {
  long long l = 0, r = 1e6;
  while (l <= r) {
    long long m = (r + l) / 2;
    if (m * m * m == n)
      return m;
    else if (m * m * m < n)
      l = m + 1;
    else if (m * m * m > n)
      r = m - 1;
  }
  return 0;
}
int main() {
  long long n, a, b;
  scanf("%lld", &n);
  for (int i = 0; i < n; ++i) {
    scanf("%lld %lld", &a, &b);
    long long res = root_search(a * b);
    if ((res > 0) && (a % res == 0) && (b % res == 0))
      printf("Yes\n");
    else
      printf("No\n");
  }
  return 0;
}
