#include <bits/stdc++.h>
using namespace std;
long long t, x, y;
long long cubeRoot(long long n) {
  long long l = 0, r = 1e6;
  while (l <= r) {
    long long mid = (l + r) / 2;
    if (mid * mid * mid == n) return mid;
    if (mid * mid * mid < n)
      l = mid + 1;
    else
      r = mid - 1;
  }
  return 0;
}
int main() {
  scanf("%d", &t);
  while (t-- && scanf("%d%d", &x, &y)) {
    long long c = x * y;
    long long cb = cubeRoot(c);
    if (cb * cb * cb == c && x % cb == 0 && y % cb == 0)
      puts("Yes");
    else
      puts("No");
  }
  return 0;
}
