#include <bits/stdc++.h>
using namespace std;
long long int Cube_Root(long long int x) {
  long long int l = 1, r = 1000005;
  while (l < r) {
    long long int mid = (l + r) / 2;
    if (mid * mid * mid >= x) {
      r = mid;
    } else {
      l = mid + 1;
    }
  }
  if (l * l * l > x) {
    return l - 1;
  } else {
    return l;
  }
}
int main() {
  int n;
  scanf("%d", &n);
  while (n--) {
    long long int a, b, temp;
    scanf("%lld%lld", &a, &b);
    temp = Cube_Root(a * b);
    if ((temp * temp * temp == a * b) && (a % temp == 0) && (b % temp == 0)) {
      printf("Yes\n");
    } else {
      printf("No\n");
    }
  }
  return 0;
}
