#include <bits/stdc++.h>
using namespace std;
bool TC() {
  long long a, b, p, s, e, mid;
  scanf("%lld%lld", &a, &b);
  p = a * b;
  for (s = 1, e = 1e6; s <= e;) {
    mid = (s + e) / 2;
    if (mid * mid * mid < p)
      s = mid + 1;
    else
      e = mid - 1;
  }
  e++;
  if (e * e * e != p) return 0;
  return a % e == 0 && b % e == 0;
}
int main() {
  int n;
  scanf("%d", &n);
  for (; n--;) {
    printf("%s\n", TC() ? "Yes" : "No");
  }
  return 0;
}
