#include <bits/stdc++.h>
using namespace std;
int main() {
  int TC;
  scanf("%d", &TC);
  while (TC--) {
    long long a, b;
    scanf("%I64d %I64d", &a, &b);
    long long n = a * b;
    long long c = (long long)ceil(pow(n, 1 / 3.));
    if (c * c * c == a * b && a % c == 0 && b % c == 0)
      puts("Yes");
    else
      puts("No");
  }
}
