#include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include using namespace std; template T gcd(T a,T b) { while(b) { a %= b; swap(a,b); } return a; } template T lcm(T a,T b) { return a / gcd(a,b) * b; } void Main() { int N; cin >> N; vector A(N); for(int i = 0;i < N;i++) { cin >> A[i]; } for(int i = 0;i < N;i++) { for(int j = i + 1;j < N;j++) { long long g = gcd(A[i],A[j]); A[i] /= g; A[j] /= g; } } sort(A.begin(),A.end()); auto sq = [](long long x) -> bool { long long ok = 0,ng = (long long)1e9 + 1; while(ng - ok > 1) { long long mid = (ok + ng) / 2; if(mid * mid <= x) { ok = mid; } else { ng = mid; } } return ok * ok == x; }; for(int i = 0;i < N;) { int j = i; while(j < N && A[j] == A[i]) { j++; } if(!sq(A[i]) && (j - i) & 1) { cout << "No\n"; return; } i = j; } cout << "Yes\n"; } int main() { ios::sync_with_stdio(false); cin.tie(nullptr); int tt = 1; cin >> tt; while(tt--) Main(); }