#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  scanf("%d", &n);
  while (n--) {
    long long int a, b;
    scanf("%lld%lld", &a, &b);
    long long c = cbrt((long double)a * b);
    long long x = a / c, y = b / c;
    bool flag = (x * x * y == a) && (y * y * x == b);
    puts(flag ? "Yes" : "No");
  }
}
