#include <bits/stdc++.h>
using namespace std;
long long T, a, b, x, ans;
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  cin >> T;
  while (T--) {
    cin >> a >> b;
    x = a * b;
    long long l = 1;
    long long r = 1000000;
    ans = -1;
    while (l <= r) {
      long long md = (l + r) / 2;
      if (md * md * md == x) {
        ans = md;
        break;
      }
      if (md * md * md < x) {
        l = md + 1;
      } else {
        r = md - 1;
      }
    }
    if (ans == -1 || (a % ans) != 0 || (b % ans) != 0) {
      cout << "No\n";
    } else {
      cout << "Yes\n";
    }
  }
}
