#include <bits/stdc++.h>
using namespace std;
vector<long long int> cube;
int main() {
  int t, u, v;
  long long int x;
  for (long long int i = 1; i <= 1000000; i++) cube.push_back(i * i * i);
  scanf("%d", &t);
  while (t--) {
    scanf("%d %d", &u, &v);
    x = (long long int)u * v;
    int p = lower_bound(cube.begin(), cube.end(), x) - cube.begin() + 1;
    if (cube[p - 1] != x)
      puts("No");
    else {
      if ((u % p) || (v % p))
        puts("No");
      else
        puts("Yes");
    }
  }
  return 0;
}
