#include <bits/stdc++.h>
#pragma 03
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#pragma GCC optimization("unroll-loops")
using namespace std;
signed main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  ;
  long long t;
  cin >> t;
  while (t--) {
    long long a, b;
    cin >> a >> b;
    long long k = floor(cbrt(a * b));
    if (k * k * k != a * b)
      cout << "No\n";
    else if (a % k == 0 && b % k == 0)
      cout << "Yes\n";
    else
      cout << "No\n";
  }
  return 0;
}
