#include <bits/stdc++.h>
using namespace std;
int a, b, n;
long long drb;
int main() {
  scanf("%d", &n);
  while (n--) {
    scanf("%d", &a);
    scanf("%d", &b);
    drb = 1LL * a * b;
    unsigned long long l = 0, r = 1e6, mid;
    while (l < r) {
      mid = (l + r + 1) / 2;
      if ((mid * mid * mid) <= drb)
        l = mid;
      else
        r = mid - 1;
    }
    if ((l * l * l) == drb && ((a % l) == 0) && ((b % l) == 0))
      printf("Yes\n");
    else
      printf("No\n");
  }
  return 0;
}
