#include <bits/stdc++.h>
using namespace std;
long long foo(long long x) {
  int l = 1, r = 1e6;
  while (r >= l) {
    long long t = (l + r) / 2;
    long long c = t * t * t;
    if (c == x)
      return t;
    else if (c > x)
      r = t - 1;
    else
      l = t + 1;
  }
  return -1;
}
int main() {
  int n;
  scanf("%d", &n);
  while (n--) {
    int a, b;
    scanf("%d%d", &a, &b);
    long long c = foo(1LL * a * b);
    if (c < 0)
      puts("No");
    else
      puts(a % c || b % c ? "No" : "Yes");
  }
}
