#include <bits/stdc++.h>
int main() {
  int T;
  scanf("%d", &T);
  while (T--) {
    long long a, b;
    scanf("%I64d%I64d", &a, &b);
    long long tmp = ceil(cbrt(a * b));
    puts(tmp * tmp * tmp == a * b && a % tmp == 0 && b % tmp == 0 ? "Yes"
                                                                  : "No");
  }
  return 0;
}
