#include <bits/stdc++.h>
using namespace std;
int main() {
  int T;
  scanf("%d", &T);
  while (T--) {
    long long a, b;
    scanf("%I64d%I64d", &a, &b);
    long long c = a * b, ans = -1;
    long long L = 1, R = 1000010;
    while (L <= R) {
      long long mid = (L + R) >> 1;
      long long x = mid * mid * mid;
      if (x == c) {
        ans = mid;
        break;
      }
      if (x > c)
        R = mid - 1;
      else
        L = mid + 1;
    }
    if (~ans && a % ans == 0 && b % ans == 0)
      puts("Yes");
    else
      puts("No");
  }
}
