#include <bits/stdc++.h>
using namespace std;
int main() {
  long long n, a, b;
  cin >> n;
  while (n--) {
    scanf("%lld %lld", &a, &b);
    long long c = cbrt(a * b) + 0.000001;
    if (c * c * c == a * b && a % c == 0 && b % c == 0) {
      printf("Yes\n");
    } else {
      printf("No\n");
    }
  }
  return 0;
}
