#include <bits/stdc++.h>
using namespace std;
int main() {
  int T;
  scanf("%d", &T);
  while (T--) {
    int a, b;
    scanf("%d%d", &a, &b);
    int64_t x = a * (int64_t)b, y = cbrtl(x) + 0.5;
    puts(y * y * y == x && a % y == 0 && b % y == 0 ? "Yes" : "No");
  }
}
