#include <bits/stdc++.h>
using namespace std;
long long min(long long a, long long b) {
  if (a > b)
    return b;
  else
    return a;
}
long long pcube(long long a) {
  long long lo = 1;
  long long hi = min(a, 1000000);
  long long mid;
  while (lo <= hi) {
    mid = (lo + hi) / 2;
    if (mid * mid * mid > a)
      hi = mid - 1;
    else if (mid * mid * mid == a)
      return mid;
    else if (mid * mid * mid < a)
      lo = mid + 1;
  }
  return 0;
}
int main() {
  int test;
  scanf("%d", &test);
  long long a, b, mul;
  while (test--) {
    scanf("%lld%lld", &a, &b);
    mul = a * b;
    long long temp = pcube(mul);
    if (temp && !(a % temp) && !(b % temp))
      printf("Yes\n");
    else
      printf("No\n");
  }
  return 0;
}
