#include <bits/stdc++.h>
using namespace std;
long long gcd(long long a, long long b) { return b ? gcd(b, a % b) : a; }
int main() {
  int ncase;
  int mark;
  scanf("%d", &ncase);
  while (ncase--) {
    long long a, b;
    mark = 0;
    scanf("%lld%lld", &a, &b);
    long long c = gcd(a, b);
    if (a % c || b % c) {
      mark = 1;
    } else {
      a /= c;
      b /= c;
      if (c % (a * b)) {
        mark = 1;
      } else {
        c /= (a * b);
        long long t = pow(c, 1.0 / 3);
        while (t * t * t < c) {
          t++;
        }
        if (t * t * t != c) {
          mark = 1;
        }
      }
    }
    if (mark) {
      printf("No\n");
    } else {
      printf("Yes\n");
    }
  }
  return 0;
}
