#include <bits/stdc++.h>
int main() {
  int ncase;
  std::cin >> ncase;
  while (ncase--) {
    long long a, b;
    scanf("%I64d%I64d", &a, &b);
    long long res = a * b;
    res = round(pow((double)res, 1.0 / 3));
    if (res * res * res != a * b or a % res or b % res)
      printf("No\n");
    else
      printf("Yes\n");
  }
  return 0;
}
