#include <bits/stdc++.h>
using namespace std;
const long long INF = 0x7f7f7f7f7f7f7f7f;
template <typename _T>
void read(_T &x) {
  _T f = 1;
  x = 0;
  char s = getchar();
  while (s > '9' || s < '0') {
    if (s == '-') f = -1;
    s = getchar();
  }
  while (s >= '0' && s <= '9') {
    x = (x << 3) + (x << 1) + (s ^ 48);
    s = getchar();
  }
  x *= f;
}
long long t;
signed main() {
  read(t);
  while (t--) {
    long long x, y;
    read(x);
    read(y);
    long long t = round(pow(x * y, 1.0 / 3));
    if (t * t * t != x * y)
      puts("No");
    else if (x % t == 0 && y % t == 0)
      puts("Yes");
    else
      puts("No");
  }
  return 0;
}
