#include <bits/stdc++.h>
using namespace std;
int main() {
  int q;
  scanf("%d", &q);
  while (q--) {
    long long x, y;
    scanf("%lld %lld", &x, &y);
    long long mul = x * y;
    long long bas = 1, son = 1e6 + 5;
    while (bas <= son) {
      long long orta = (bas + son) / 2;
      if (orta * orta * orta > mul)
        son = orta - 1;
      else
        bas = orta + 1;
    }
    if (son * son * son == mul && x % son == 0 && y % son == 0) {
      printf("Yes\n");
    } else {
      printf("No\n");
    }
  }
}
