#define _USE_MATH_DEFINES #include using namespace std; #define FOR(i,m,n) for(int i=(m);i<(n);++i) #define REP(i,n) FOR(i,0,n) #define ALL(v) (v).begin(),(v).end() using ll = long long; constexpr int INF = 0x3f3f3f3f; constexpr long long LINF = 0x3f3f3f3f3f3f3f3fLL; constexpr double EPS = 1e-8; constexpr int MOD = 998244353; // constexpr int MOD = 1000000007; constexpr int DY4[]{1, 0, -1, 0}, DX4[]{0, -1, 0, 1}; constexpr int DY8[]{1, 1, 0, -1, -1, -1, 0, 1}; constexpr int DX8[]{0, -1, -1, -1, 0, 1, 1, 1}; template inline bool chmax(T& a, U b) { return a < b ? (a = b, true) : false; } template inline bool chmin(T& a, U b) { return a > b ? (a = b, true) : false; } struct IOSetup { IOSetup() { std::cin.tie(nullptr); std::ios_base::sync_with_stdio(false); std::cout << fixed << setprecision(20); } } iosetup; std::vector prime_sieve(const int n, const bool get_only_prime) { std::vector smallest_prime_factor(n + 1), prime; std::iota(smallest_prime_factor.begin(), smallest_prime_factor.end(), 0); for (int i = 2; i <= n; ++i) { if (smallest_prime_factor[i] == i) prime.emplace_back(i); for (const int p : prime) { if (i * p > n || p > smallest_prime_factor[i]) break; smallest_prime_factor[i * p] = p; } } return get_only_prime ? prime : smallest_prime_factor; } int main() { const vector primes = prime_sieve(1000000, true); const int p_size = primes.size(); vector sq(p_size); REP(i, p_size) sq[i] = 1LL * primes[i] * primes[i]; int t; cin >> t; vector ps; while (t--) { int n; cin >> n; ps.clear(); while (n--) { ll a; cin >> a; REP(i, p_size) { while (a % sq[i] == 0) a /= sq[i]; if (a % primes[i] == 0) { ps.emplace_back(primes[i]); a /= primes[i]; } } if (a == 1) continue; const ll si = llround(sqrt(a)); if (si * si == a) continue; ps.emplace_back(a); } if (ps.size() % 2 == 1) { cout << "No\n"; continue; } sort(ALL(ps)); const int ps_size = ps.size(); bool is_sq = true; for (int i = 0; i < ps_size; i += 2) { if (ps[i] != ps[i + 1]) { is_sq = false; break; } } cout << (is_sq ? "Yes\n" : "No\n"); } return 0; }