#include <bits/stdc++.h>
using namespace std;
signed main() {
  long long t, a, b;
  scanf("%lld", &t);
  while (t--) {
    scanf("%lld%lld", &a, &b);
    long long m = pow(a * b, (1.0 / 3)) + 0.5;
    puts((m * m * m != a * b || a % m || b % m) ? "No" : "Yes");
  }
}
