#include <bits/stdc++.h>
using namespace std;
int main() {
  long long n, a, b;
  scanf("%lld", &n);
  while (n--) {
    scanf("%lld %lld", &a, &b);
    long long x = cbrt(a * 1LL * b);
    bool ok = false;
    for (int i = -1; i <= 1; i++) {
      if (x + i < 1) continue;
      if ((x + i) * (x + i) * (x + i) == a * b) {
        if (a % (x + i) == 0 && b % (x + i) == 0) ok = true;
      }
    }
    if (ok)
      printf("Yes\n");
    else
      printf("No\n");
  }
  return 0;
}
