#include <bits/stdc++.h>
using namespace std;
template <typename Arg1>
void __f(const char* name, Arg1&& arg1) {
  cerr << name << " : " << arg1 << std::endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args) {
  const char* comma = strchr(names + 1, ',');
  cerr.write(names, comma - names) << " : " << arg1 << " | ";
  __f(comma + 1, args...);
}
int main() {
  int t;
  scanf("%d", &t);
  while (t--) {
    long long int a, b;
    scanf("%lld", &a);
    scanf("%lld", &b);
    long long int cube = a * 1LL * b;
    long long int lo = 1, hi = 1000001, ans = -1;
    while (lo <= hi) {
      long long int mid = (lo + hi) / 2;
      long long int tmp = mid * mid * mid;
      if (tmp == cube) {
        ans = mid;
        break;
      } else if (tmp > cube)
        hi = mid - 1;
      else
        lo = mid + 1;
    }
    int fl = 0;
    if (ans != -1) {
      if (a % ans == 0 && b % ans == 0) fl = 1;
    }
    if (fl)
      printf("Yes\n");
    else
      printf("No\n");
  }
  return 0;
}
