#include <bits/stdc++.h>
using namespace std;
long long tr[1000010];
int main() {
  for (long long i = 0; i < 1000010; i++) {
    tr[i] = i * i * i;
  }
  int t;
  scanf("%d", &t);
  while (t--) {
    long long a, b;
    scanf("%I64d %I64d", &a, &b);
    int l = 1, r = 1000010;
    int mid;
    while (l <= r) {
      mid = (l + r) / 2;
      if (tr[mid] > a * b)
        r = mid - 1;
      else if (tr[mid] < a * b)
        l = mid + 1;
      else if (tr[mid] == a * b) {
        break;
      }
    }
    if (a % mid == 0 && b % mid == 0)
      printf("Yes\n");
    else
      printf("No\n");
  }
}
