#include<bits/stdc++.h> #define int long long #define ll long long usingnamespace std;
constint N = 1e6 + 66, mod = 1e9 + 7;
int n, cnt; int v[N], mp[N], pri[N], vis[N], las[N]; vector <int> p[N];
inlinevoidpres_dou() { int i, j; for (i = 2; i < 1e6; ++ i) { if (! v[i]) pri[++ cnt] = i, mp[i] = i; for (j = 1; j <= cnt && pri[j] * i < 1e6; ++ j) { v[i * pri[j]] = 1; mp[i * pri[j]] = pri[j]; if (i % pri[j] == 0) break; } } return; }
inlinevoiddfs(int x) { vis[x] = 1; for (int i = 0; i < (int)p[x].size(); ++ i) if (! vis[p[x][i]]) dfs(p[x][i]); return; }
inlinevoidyhm_func() { int i, x; n = read(); for (i = 1; i <= cnt; ++ i) las[pri[i]] = 0; for (i = 1; i <= n; ++ i) { vis[i] = 0, p[i].clear(); x = read(); while (x > 1) { int tmp = mp[x]; while (x % tmp == 0) x /= tmp; if (las[tmp]) p[i].push_back(las[tmp]), p[las[tmp]].push_back(i); las[tmp] = i; } } int res = 1; for (i = 1; i <= n; ++ i) if (! vis[i]) dfs(i), res = res * 2 % mod; return (void)(put((res - 2 + mod) % mod)); }
signedmain() { pres_dou(); int T = read(); while (T --) yhm_func();