#include <bits/stdc++.h>
using namespace std;
int gcd(int a, int b) {
  while (a != 0 && b != 0) {
    if (a > b)
      a %= b;
    else
      b %= a;
  }
  return a + b;
}
bool is_cube(long long a, long long b) {
  if (a == b) return true;
  if (a % b != 0) return false;
  long long x = a / b;
  long long cbrt__ = (long long)(0.01 + pow((double)x, 1.0 / 3.0));
  return cbrt__ * cbrt__ * cbrt__ == x;
}
int main(int argc, char* argv[]) {
  cin.sync_with_stdio(false);
  cout.sync_with_stdio(false);
  int N;
  scanf("%d", &N);
  for (int the_test = 0; the_test < N; the_test++) {
    int a, b;
    scanf("%d%d", &a, &b);
    int g = gcd(a, b);
    if (is_cube((long long)g, (((long long)a / (long long)g) *
                               ((long long)b / (long long)g)))) {
      printf("Yes\n");
    } else {
      printf("No\n");
    }
  }
  return 0;
}
