#include using namespace std; bool is_square(long long x) { if (x == 1) return true; long long ok = 5e9; long long ng = 0; while (abs(ok - ng) > 1) { long long m = (ok + ng) / 2; if (m * m == x) return true; else if (m * m > x) ok = m; else ng = m; } if (ok * ok == x) return true; else return false; } int main() { int t; cin >> t; while (t--) { int n; cin >> n; vector a(n); for (int i = 0; i < n; i++) { cin >> a[i]; } for (int i = 0; i < n - 1; i++) { for (int j = i + 1; j < n; j++) { long long g = __gcd(a[i], a[j]); a[i] /= g; a[j] /= g; } } bool ok = true; for (int i = 0; i < n; i++) { if (is_square(a[i])) continue; ok = false; } cout << (ok ? "Yes" : "No") << endl; } return 0; }