#include <bits/stdc++.h>
using namespace std;
long long cubic_root(long long x) {
  long long l = 0, 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);
  while (n--) {
    long long int a, b;
    scanf("%I64d %I64d", &a, &b);
    long long s3p3 = a * b;
    long long sp = cubic_root(s3p3);
    bool isRoot = true;
    if (s3p3 != sp * sp * sp) isRoot = false;
    if (isRoot) {
      if (a % sp == 0 && b % sp == 0) {
        puts("Yes");
        continue;
      }
    }
    puts("No");
  }
  return 0;
}
