#include <bits/stdc++.h>
using namespace std;
int n;
int main() {
  cin >> n;
  for (int i = 1; i <= n; i++) {
    long long a, b;
    scanf("%lld %lld", &a, &b);
    long long c = round(pow(a * b, 1.0 / 3));
    if (c * c * c == a * b && a % c == 0 && b % c == 0)
      printf("Yes\n");
    else
      printf("No\n");
  }
  return 0;
}
