#include <bits/stdc++.h>
using namespace std;
void FAST() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
}
void TEST() {
  long long a, b;
  cin >> a >> b;
  long long c = cbrt(a * b);
  long long aa = a / c, bb = b / c;
  bool ok = (aa * aa * bb == a) && (bb * bb * aa == b);
  cout << (ok ? "Yes\n" : "No\n");
}
int main() {
  FAST();
  int T = 1;
  cin >> T;
  while (T--) {
    TEST();
  }
  return 0;
}
