#include <bits/stdc++.h>
using namespace std;
int main() {
  int t;
  int a, b;
  int x, y, z;
  long long mul, nmul;
  int j;
  scanf("%d", &t);
  while (t--) {
    scanf("%d%d", &a, &b);
    y = min(a, b);
    x = max(a, b);
    mul = 1LL * x * y;
    j = (int)(pow(mul, 1 * 1.0 / 3) + 0.5);
    nmul = 1LL * j * j * j;
    if (mul != nmul)
      printf("No\n");
    else if (x % j != 0 || y % j != 0)
      printf("No\n");
    else
      printf("Yes\n");
  }
  return 0;
}
