#include #include #include using namespace std; typedef long long ll; long long gcd(long long n, long long m) { if (m == 0) { return n; } return gcd(m, n % m); } struct prime_sturcture { int max_n; std::vector p; std::vector prime_list; prime_sturcture(int max_n) : max_n(max_n), p(max_n + 1, true) { p[0] = p[1] = false; for (int i = 2; i <= max_n; i++) { if (p[i]) { prime_list.push_back(i); for (int j = i * 2; j <= max_n; j += i) { p[j] = false; } } } } bool is_prime(int n) { assert(n <= max_n); return p[n]; } int size() { return prime_list.size(); } const int operator[](int i) const { assert(i < (int)prime_list.size()); return prime_list[i]; } std::vector::const_iterator begin() { return prime_list.begin(); } std::vector::const_iterator end() { return prime_list.end(); } }; bool is_square(ll x) { ll left = -1, right = 1000000001; while (right - left > 1) { ll mid = (right + left) / 2; if (mid * mid >= x) { right = mid; } else { left = mid; } } return right * right == x; } int main() { ios::sync_with_stdio(false); cin.tie(nullptr); prime_sturcture prime(1000000); int t; cin >> t; while (t--) { int n; cin >> n; bool b[1000005]{0}; ll a[1005]; for (int i = 0; i < n; i++) { cin >> a[i]; for (int p : prime) { if (a[i] % p == 0) { while (a[i] % ((ll)p * p) == 0) { a[i] /= p * p; } if (a[i] % p == 0) { a[i] /= p; b[p] ^= 1; } } } if (is_square(a[i])) { a[i] = 1; } } for (int i = 0; i < n; i++) { for (int j = i + 1; j < n; j++) { ll g = gcd(a[i], a[j]); a[i] /= g; a[j] /= g; } } bool f = false; for (int p : prime) { f |= b[p]; } for (int i = 0; i < n; i++) { f |= (a[i] > 1); } cout << (!f ? "Yes\n" : "No\n"); } }