#include <bits/stdc++.h>
int main() {
  int n;
  int i;
  scanf("%d", &n);
  for (i = 0; i < n; i++) {
    int x, y;
    int r, a, b;
    scanf("%d%d", &x, &y);
    r = (int)round(cbrtl((long double)x * y));
    a = x / r;
    b = y / r;
    if (x % r == 0 && y % r == 0 && r == a * b)
      printf("Yes\n");
    else
      printf("No\n");
  }
  return 0;
}
