#include <bits/stdc++.h>
using namespace std;
long long int cuberoot(long long int n) {
  long long int low = 1;
  long long int high = 1000000;
  long long int mid;
  while (low <= high) {
    mid = (low + high) / 2;
    if (mid * mid * mid == n)
      return mid;
    else if (mid * mid * mid > n)
      high = mid - 1;
    else
      low = mid + 1;
  }
  return -1;
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  ;
  int t;
  scanf("%d", &t);
  long long int a, b, x;
  while (t--) {
    scanf("%lld%lld", &a, &b);
    x = cuberoot(a * b);
    if (x * x * x != a * b)
      printf("No");
    else if (a % x == 0 && b % x == 0)
      printf("Yes");
    else
      printf("No");
    printf("\n");
  }
}
