#include <bits/stdc++.h>
using namespace std;
long long cubic_root(long long x) {
  long long l = 0;
  long long r = 1000005;
  while (l != r) {
    long long m = (l + r + 1) / 2;
    if (m * m * m > x) {
      r = m - 1;
    } else {
      l = m;
    }
  }
  return l;
}
int main() {
  int n;
  scanf("%d", &n);
  for (int i = 0; i < n; i++) {
    long long a, b;
    scanf("%I64d %I64d", &a, &b);
    long long x = cubic_root(a * b);
    if (x * x * x != a * b) {
      printf("No\n");
    } else if (a % x == 0 && b % x == 0) {
      printf("Yes\n");
    } else {
      printf("No\n");
    }
  }
}
