#include <bits/stdc++.h>
int main() {
  int T;
  scanf("%d", &T);
  while (T--) {
    long long x, y;
    scanf("%I64d%I64d", &x, &y);
    long long t = x * y;
    bool flag = false;
    long long l = 1, r = 1e6 + 10, m;
    while (l <= r) {
      m = (l + r) / 2;
      if (m * m * m == t) {
        flag = true;
        break;
      } else if (m * m * m > t) {
        r = m - 1;
      } else {
        l = m + 1;
      }
    }
    if (flag) {
      if (x % m != 0 || y % m != 0)
        puts("NO");
      else
        puts("Yes");
    } else
      puts("No");
  }
}
