#include <bits/stdc++.h>
using namespace std;
const int INF = 0x3f3f3f3f, MOD = 1e9 + 7;
long long cube(long long c) {
  long long l = 1, r = 1e6, mid;
  while (l < r) {
    mid = (l + r) / 2;
    if ((mid * mid * mid) < c)
      l = mid + 1;
    else
      r = mid;
  }
  return l;
}
int main() {
  int n;
  scanf("%d", &n);
  for (int t = 0; t < n; t++) {
    long long a, b;
    scanf("%lld%lld", &a, &b);
    long long c = cube(a * b);
    ((void)0);
    if (c * c * c != a * b) {
      printf("No\n");
      continue;
    }
    ((void)0);
    if (a % c == 0 and b % c == 0)
      printf("Yes\n");
    else
      printf("No\n");
  }
}
