#include <bits/stdc++.h>
using namespace std;
bool solve() {
  int a, b;
  scanf("%d %d", &a, &b);
  int both = int(floor(pow((double)a * b, 1.0 / 3) + 0.5));
  if (both == 0) return a == 1 && b == 1;
  if (a % both != 0 || b % both != 0) return false;
  if ((long long)a * b != (long long)both * both * both) return false;
  long long A = a / both;
  long long B = b / both;
  if (B * B * A != b || A * A * B != a) return false;
  return true;
}
int main() {
  int t;
  cin >> t;
  while (t--) {
    if (solve())
      puts("Yes");
    else
      puts("No");
  }
}
