#include <bits/stdc++.h>
using namespace std;
map<long long int, int> mp;
int main() {
  long long int tmp;
  for (int i = 0; i < 1000008; i++) {
    tmp = 1LL * i * i * i;
    mp[tmp] = i;
  }
  int n, a, b;
  scanf("%d", &n);
  while (n--) {
    scanf("%d%d", &a, &b);
    tmp = 1LL * a * b;
    if (mp.count(tmp)) {
      tmp = mp[tmp];
      int c, d;
      c = a / tmp;
      d = b / tmp;
      if (1LL * c * c * d == a && 1LL * d * d * c == b)
        printf("Yes\n");
      else
        printf("No\n");
    } else {
      printf("No\n");
    }
  }
}
