#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;
template <typename T>
using OrderedSet = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
#define v vector
#define int long long
#define vin vector <int>
#define pii pair <int, int>
#define all(a) a.begin(), a.end()
#define yes cout << "YES\n"
#define Yes cout << "Yes\n"
#define no cout << "NO\n"
#define No cout << "No\n"
#define rep(i, a, b) for(int i = a; i < b; i++)
#define repn(i, a, b) for(int i = a; i <= b; i++)
#define rev(i, a, b) for(int i = a; i >= b; i--)
int mod = 1e9+7;
void fastIO(){
ios_base::sync_with_stdio(false);
cin.tie(NULL);cout.tie(NULL);
}
void pk() {
int n; cin >> n;
vin p(n);
rep(i, 0, n) cin >> p[i];
v<vin> s(1<<n);
rep(i, 0, 1<<n){
rep(j, 0, n){
if(i&1<<j){
s[i].push_back(p[j]);
}
}
}
int ans = 1;
vin gc(n);
rep(i, 0, 1<<n){
int g = 0;
int a = s[i].size();
rep(j, 0, a){
g = __gcd(g, s[i][j]);
}
gc[a-1] += g;
}
rep(i, 0, n) ans = (ans*gc[i])%mod;
cout << ans <<'\n';
}
int32_t main(){
fastIO();
int t = 1;
cin >> t;
while(t--) pk();
return 0;
}