#include <bits/stdc++.h>
using namespace std;
int main() {
  int64_t n;
  cin >> n;
  while (n--) {
    int64_t a, b;
    scanf("%I64d%I64d", &a, &b);
    int64_t c = a * b;
    int64_t cu = ceil(cbrt(c));
    if (cu * cu * cu == c && a % cu == 0 && b % cu == 0)
      cout << "YES\n";
    else
      cout << "NO\n";
  }
}
