#include <bits/stdc++.h>
using namespace std;
long long cubic_root(long long num) {
  long long ans = 0;
  long long low = 1, high = 1e6 + 100;
  while (low <= high) {
    long long mid = (low + high) / 2, t;
    t = mid * mid * mid;
    if (t == num) {
      ans = mid;
      break;
    } else if (t > num) {
      high = mid - 1;
    } else {
      low = mid + 1;
    }
  }
  return ans;
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  int n;
  scanf("%d", &n);
  while (n--) {
    long long a, b;
    scanf("%lld %lld", &a, &b);
    long long cbr = cubic_root(a * b);
    if (cbr && a % cbr == 0 && b % cbr == 0) {
      puts("Yes");
    } else {
      puts("No");
    }
  }
  return 0;
}
