#include <bits/stdc++.h>
using namespace std;
int n;
long long a, b;
int solve(long long x) {
  long long l = 1, r = 1e6;
  long long mid;
  while (l <= r) {
    mid = (l + r) / 2;
    if (mid * mid * mid == x) return mid;
    if (mid * mid * mid < x)
      l = mid + 1;
    else
      r = mid - 1;
  }
  return 0;
}
int main() {
  while (~scanf("%lld", &n)) {
    while (n--) {
      scanf("%lld %lld", &a, &b);
      long long mid = solve(a * b);
      if (mid && a % mid == 0 && b % mid == 0)
        puts("Yes");
      else
        puts("No");
    }
  }
  return 0;
}
