#include <bits/stdc++.h>
using namespace std;
int main() {
  long long int n, a, b;
  scanf("%lld", &n);
  while (n--) {
    scanf("%lld%lld", &a, &b);
    long long int c = a * b;
    long long int d = round(pow((double)c, (1.0) / 3));
    if (a % d > 0 || b % d > 0 || c != d * d * d) {
      printf("No\n");
    } else
      printf("Yes\n");
  }
}
