#include <bits/stdc++.h>
using namespace std;
int main() {
  int t;
  scanf("%d", &t);
  while (t--) {
    long long int a, b;
    scanf("%lld%lld", &a, &b);
    long long int l = 1, r = 1000000;
    long long mid;
    long long mul = a * b;
    long long rs;
    while (l <= r) {
      mid = (l + r) >> 1;
      rs = mid * mid * mid;
      if (rs == mul) break;
      if (rs > mul)
        r = mid - 1;
      else if (rs < mul)
        l = mid + 1;
    }
    if (l <= r && a % mid == 0 && b % mid == 0)
      puts("Yes");
    else
      puts("No");
  }
  return 0;
}
