#include <bits/stdc++.h>
using namespace std;
const int MAXN = 100000 + 50;
const int INF = 1 << 30;
int n;
long long a, b;
int main() {
  scanf("%d", &n);
  while (n--) {
    scanf("%I64d%I64d", &a, &b);
    long long t = a * b;
    long long l = 1, r = 1000000;
    while (l < r) {
      long long mid = l + (r - l + 1) / 2;
      long long ans = mid * mid * mid;
      if (ans <= t)
        l = mid;
      else
        r = mid - 1;
    }
    if (l * l * l == t && a >= l && b >= l && !(a % l) && !(b % l))
      puts("Yes");
    else
      puts("No");
  }
  return 0;
}
