#include <bits/stdc++.h>
int main() {
  long long int n, a, b, mid;
  while (~scanf("%lld", &n)) {
    while (n--) {
      scanf("%lld%lld", &a, &b);
      int l = 1, r = 1000000;
      int flag = 0;
      while (l <= r) {
        mid = (l + r) / 2;
        if (mid * mid * mid == a * b && a % mid == 0 && b % mid == 0) {
          flag = 1;
          printf("Yes\n");
          break;
        } else if (mid * mid * mid < a * b)
          l = mid + 1;
        else
          r = mid - 1;
      }
      if (!flag) printf("No\n");
    }
  }
  return 0;
}
