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