#include <bits/stdc++.h>
using namespace std;
int main() {
  int T;
  cin >> T;
  int cnt = 1;
  while (T--) {
    long long A, B, C;
    scanf("%lld %lld", &A, &B);
    C = A * B;
    long long sm = (long long)(pow(C, 1 / 3.0) + 0.5);
    if (sm * sm * sm != C || sm > min(A, B) || A % sm || B % sm)
      printf("No\n");
    else
      printf("Yes\n");
  }
}
