#include <bits/stdc++.h>
double eps = 1e-9;
using namespace std;
unordered_map<int, bool> cubes;
int main() {
  for (long long i = 1; i <= 1000000000000000000LL; i++) {
    if (i * i * i > 1000000000000000000LL) break;
    cubes[i * i * i] = 1;
  }
  int n;
  cin >> n;
  while (n--) {
    int a, b;
    scanf("%d %d", &a, &b);
    if (a == 1 || b == 1) {
      if (a == b)
        puts("Yes");
      else
        puts("No");
      continue;
    }
    if (cubes.find((long long)a * (long long)b) == cubes.end()) {
      puts("No");
      continue;
    }
    int c = 2;
    bool bad = 0;
    while (c * c <= a) {
      int d1 = 0, d2 = 0;
      if (a % c == 0) {
        while (a % c == 0) {
          a /= c;
          d1++;
        }
        while (b % c == 0) {
          b /= c;
          d2++;
        }
        int v = (d1 + d2) % 3;
        if (v) {
          bad = 1;
          break;
        }
        v = (d1 + d2) / 3;
        int x = d2 - v;
        int y = d2 - 2 * x;
        if (x < 0 || y < 0) {
          bad = 1;
          break;
        }
      }
      c++;
    }
    if (a != 1 && b != 1) {
      if (a > b) swap(a, b);
      if (!bad) bad = ((long long)a * (long long)a) != (long long)b;
    } else if (!(a == 1 && b == 1))
      bad = 1;
    bad ? puts("No") : puts("Yes");
  }
}
