T=int(input()) from math import gcd for _ in range(T): n=int(input()) a=list(map(int,input().split())) for i in range(n-1): for j in range(i+1,n): g=gcd(a[i],a[j]) a[i]//=g a[j]//=g f=1 for i in range(n): ok=10**10 ng=0 while ok-ng>1: m=(ok+ng)//2 if m*m>=a[i]: ok=m else: ng=m f&=ok*ok==a[i] print(["No","Yes"][f])