#include <bits/stdc++.h>
long long a, b;
int n;
int main() {
  int i;
  scanf("%d", &n);
  while (n--) {
    scanf("%lld%lld", &a, &b);
    long long p = a * b, c;
    c = (long long)round(pow((double)p, (1.0) / (3.0)));
    if (c == 0 || (c * c * c) != p)
      printf("No\n");
    else if (a % c == 0 && b % c == 0)
      printf("Yes\n");
    else
      printf("No\n");
  }
  return 0;
}
