#include <bits/stdc++.h>
using namespace std;
bool cmp(pair<long long, long long> a, pair<long long, long long> b) {
  if (a.second == b.second) return a.first < b.first;
  return a.second < b.second;
}
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  long long m, a, ans, c, g, d;
  cin >> m;
  while (m--) {
    cin >> a >> c;
    ans = 0;
    for (int b = 1e6; b >= 1; b /= 2) {
      while ((ans + b) * (ans + b) * (ans + b) <= c * a) ans += b;
    }
    if (ans * ans * ans == c * a) {
      if (c % ans == 0 && a % ans == 0)
        cout << "yes";
      else
        cout << "no";
    } else
      cout << "no";
    cout << "\n";
  }
  return 0;
}
