require 'prime' T = gets.to_i def f(x) ok = 1 ng = x while (ok - ng).abs >= 2 v = (ok + ng) / 2 if v ** 2 <= x ok = v else ng = v end end ok ** 2 == x end T.times do n = gets.to_i a = gets.split.map(&:to_i) 0.upto(n - 2) do |i| (i + 1).upto(n - 1) do |j| gcd = a[i].gcd(a[j]) a[i] /= gcd a[j] /= gcd end end if a.all? { |v| f(v) } puts 'Yes' else puts 'No' end end