#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  int tc;
  cin >> tc;
  while (tc--) {
    long long a, b;
    cin >> a >> b;
    long long pro = (a * b);
    long long c = cbrt((long double)(pro));
    if (c * c * c != pro)
      cout << "No" << '\n';
    else if (a % c == 0 && b % c == 0)
      cout << "Yes" << '\n';
    else
      cout << "No" << '\n';
  }
  return 0;
}
