#include <bits/stdc++.h>
using namespace std;
const int MAXR = 1000005;
long long cubic_root(long long x) {
  long long l = 1, r = MAXR;
  while (l != r) {
    long long m = (l + r) / 2;
    if (m * m * m >= x)
      r = m;
    else
      l = m + 1;
  }
  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)
      puts("No");
    else if (a % x == 0 && b % x == 0)
      puts("Yes");
    else
      puts("No");
  }
  return 0;
}
