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