#include <stdio.h>
#include <atcoder/all>
#include <bits/stdc++.h>
using namespace std;
using namespace atcoder;
using mint = modint998244353;
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define Inf32 1000000001
#define Inf64 4000000000000000001

bool check(long long n){
	long long ok = 1,ng = 1000000001;
	while(ng-ok>1LL){
		long long mid = (ok+ng)/2;
		if(mid*mid <= n)ok = mid;
		else ng = mid;
	}
	return ok*ok==n;
}

int main(){
	
	int _t;
	cin>>_t;
	
	rep(_,_t){
		int n;
		cin>>n;
		
		vector<long long> a(n);
		rep(i,n){
			cin>>a[i];
			rep(j,i){
				long long g = gcd(a[i],a[j]);
				a[i]/=g;
				a[j]/=g;
			}
		}
		
		bool f = true;
		rep(i,n){
			if(!check(a[i]))f = false;
		}
		if(f)cout<<"Yes"<<endl;
		else cout<<"No"<<endl;
		
	}
	return 0;
}