#include <bits/stdc++.h>
using namespace std;
const int maxn = 1e5 + 10;
int cnt1, cnt2;
int prime_num1[maxn], prime_num2[maxn];
int main() {
  int n;
  scanf("%d", &n);
  for (int i = (1); i <= (n); i++) {
    cnt1 = cnt2 = 0;
    long long a, b, flag = 1, tot = 0, down;
    scanf("%lld%lld", &a, &b);
    tot = a * b;
    down = (unsigned long long)(pow(tot, 1.0 / 3) + 0.5);
    if (down * down * down != tot)
      flag = 0;
    else if (a % down)
      flag = 0;
    else if (b % down)
      flag = 0;
    if (flag)
      printf("Yes\n");
    else
      printf("No\n");
  }
  return 0;
}
