#include <bits/stdc++.h>
using namespace std;
long long cubeRoot(long long a) {
  long long int left = 1;
  long long right = a;
  while (left <= right) {
    double mid = left + (right - left) / 2;
    if (mid * mid * mid == a) {
      return mid;
    } else if (left == mid || right == mid)
      break;
    else if (mid * mid * mid < a) {
      left = mid;
    } else {
      right = mid;
    }
  }
  return -1;
}
int main() {
  int n;
  scanf("%d", &n);
  while (n--) {
    int a, b;
    scanf("%d%d", &a, &b);
    long long ab = (long long)a * b;
    long long int root = cubeRoot(ab);
    if ((root * root * root) != ab)
      printf("No\n");
    else {
      if (a % root == 0) {
        if (b % root == 0) {
          printf("Yes\n");
          continue;
        }
      }
      printf("No\n");
    }
  }
  return 0;
}
