#include <bits/stdc++.h>
using namespace std;
using ll = long long;
int main() {
  ios::sync_with_stdio(false);
  ll n;
  cin >> n;
  ll a, b, x, y, m;
  while (n--) {
    cin >> a >> b;
    x = 0, y = 1000000;
    while (x <= y) {
      m = x + (y - x) / 2;
      if (m * m * m == a * b) {
        x = m;
        break;
      }
      if (m * m * m > a * b)
        y = m - 1;
      else
        x = m + 1;
    }
    if (a % x or b % x)
      printf("No\n");
    else
      printf("Yes\n");
  }
  return 0;
}
