#include <bits/stdc++.h>
using namespace std;
int n;
long long int a, b;
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  scanf("%d", &n);
  for (int i = 0; i < n; ++i) {
    scanf("%d %d", &a, &b);
    long long int prod = a * b;
    long long int cubert = round(cbrt(prod));
    bool good = false;
    if (cubert * cubert * cubert == prod) {
      if (a % cubert == 0 && b % cubert == 0) {
        good = true;
      }
    }
    if (good) {
      printf("Yes\n");
    } else {
      printf("No\n");
    }
  }
  return 0;
}
