#include <bits/stdc++.h>
using namespace std;
int a, b, k, u, v;
map<int, bool> OK;
int GCD(int a, int b) { return b == 0 ? a : GCD(b, a % b); }
void solve() {
  scanf("%d%d", &a, &b);
  k = GCD(a, b);
  u = a / k;
  v = b / k;
  if (k % u != 0) {
    puts("No");
    return;
  } else
    k /= u;
  if (k % v != 0) {
    puts("No");
    return;
  } else
    k /= v;
  if (!OK[k]) {
    puts("No");
    return;
  }
  puts("Yes");
}
void init() {
  for (int i = 1; i <= 1000; i++) OK[i * i * i] = true;
}
int main() {
  init();
  int nT;
  scanf("%d", &nT);
  while (nT--) solve();
}
