import sys input = sys.stdin.readline from math import gcd T=int(input()) for tests in range(T): N=int(input()) A=list(map(int,input().split())) for i in range(N): for j in range(i+1,N): x=gcd(A[i],A[j]) if x!=1: A[i]//=x A[j]//=x for a in A: x=round(a**(1/2)) if x*x==a: pass else: print("No") break else: print("Yes")