from math import gcd def solve(): n = int(input()) A = list(map(int, input().split())) for i in range(n): if A[i] == 1: continue for j in range(i + 1, n): g = gcd(A[i], A[j]) A[i] //= g A[j] //= g if A[i] != 1: x = int(A[i] ** 0.5) while x * x >= A[i]: x -= 1 while x * x < A[i]: x += 1 if x * x != A[i]: print("No") return A[i] = 1 print("Yes") for _ in range(int(input())): solve()