#include <bits/stdc++.h>
using namespace std;
int main() {
  ios::sync_with_stdio(0);
  int n;
  long long tich, a, b, s, l;
  cin >> n;
  for (int i = 1; i <= n; i++) {
    cin >> a >> b;
    tich = a * b;
    s = pow(tich, (float)1 / 3);
    l = s * s * s;
    if (l == tich && a % s == 0 && b % s == 0)
      printf("Yes\n");
    else
      printf("No\n");
  }
}
