#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define pb push_back
#define debug cout<<"check"<<endl;cout.flush();
#define all(x) (x).begin(),(x).end()
#define endl '\n'
const ll N=200005;
const ll mod=1000000007;
const ll INF=2e18L+5;
ll gcd(ll a, ll b){ while (b){ a %= b; swap(a, b);} return a;}
ll lcm(ll a, ll b){ return (a*b/gcd(a, b));}
void solve(){
ll n;
cin>>n;
vector<ll>v;
for(ll i=0;i<n;i++){
ll a;
cin>>a;
v.pb(a);
}
vector<ll>sm(n+1,0);
for(ll i=0;i<(1LL<<n);i++){
ll gc=0;
for(ll j=0;j<n;j++){
if(i&(1LL<<j))gc=gcd(gc,v[j]);
}
sm[__builtin_popcount(i)]+=gc;
sm[__builtin_popcount(i)]%=mod;
}
ll ans=1;
for(ll i=1;i<=n;i++){
ans*=sm[i];
ans%=mod;
}
cout<<ans<<endl;
}
int32_t main(){
ios::sync_with_stdio(false);cin.tie(nullptr);
int t=1;
cin>>t;
for(int i=1;i<=t;i++){
solve();
}
return 0;
}