import sys input = lambda :sys.stdin.readline()[:-1] ni = lambda :int(input()) na = lambda :list(map(int,input().split())) yes = lambda :print("yes");Yes = lambda :print("Yes");YES = lambda : print("YES") no = lambda :print("no");No = lambda :print("No");NO = lambda : print("NO") ####################################################################### from math import gcd def f(x): ok = 0 ng = 10**9+1 while ng-ok > 1: d = ok+ng>>1 if d*d <= x: ok = d else: ng = d return ok*ok == x for _ in range(ni()): n = ni() a = na() for i in range(n): for j in range(i+1,n): g = gcd(a[i],a[j]) a[i] //= g a[j] //= g ok = 1 for i in range(n): if not f(a[i]): ok = 0 break if ok: Yes() else: No()