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