#include <bits/stdc++.h>
using namespace std;
const int INF = 0x3f3f3f3f;
const long long LINF = 0x3f3f3f3f3f3f3f3f;
const long long mod = 1e9 + 7;
const double PI = acos(-1.0);
const double eps = 1e-10;
int T;
long long a, b, ka, kb;
bool solve() {
  if (a * a % b) return false;
  long long l = 1LL, r = 1e6 + 5, p = a * a / b;
  while (r - l > 1) {
    long long mid = l + r >> 1;
    if (mid * mid * mid > p)
      r = mid;
    else
      l = mid;
  }
  if (l * l * l != p || l * b % a) return false;
  ka = l, kb = l * b / a;
  return a == ka * ka * kb && b == ka * kb * kb;
}
int main() {
  scanf("%d", &T);
  while (T--) {
    scanf("%I64d %I64d", &a, &b);
    if (a < b) swap(a, b);
    puts(solve() ? "Yes" : "No");
  }
  return 0;
}
