#include <bits/stdc++.h>
using namespace std;
const int maxn = 1e6 + 10;
const double eps = 1e-8;
long long n, a, b;
int main() {
  ios::sync_with_stdio(0), cin.tie(0);
  scanf("%lld", &n);
  while (n--) {
    scanf("%lld%lld", &a, &b);
    long long x = pow(a * b, 1.0 / 3);
    while (x * x * x < a * b) x++;
    if (fabs(x * x * x - a * b) < eps) {
      if (a % x == 0 && b % x == 0)
        printf("Yes\n");
      else
        printf("No\n");
    } else
      printf("No\n");
  }
  return 0;
}
