#include <cstdio> #include <cstring> #include <iostream> #include <map> using namespace std; const int mod = 1000000007; bool pd[10000]; int t,n,pp,p[1000],a[100005],fa[100005]; map <int, int> Map; int z(int x){ if (fa[x] == x) return x; return fa[x] = z(fa[x]); } void bin(int x,int y){ // printf("%d %d\n",x,y); x = z(x); y = z(y); fa[x] = y; } int main() { scanf("%d",&t); while (t--){ scanf("%d",&n); Map.clear(); pp = 0; for (int i = 2; i <= 1000; i++) pd[i] = true; for (int i = 2; i <= 1000; i++) if (pd[i]){ for (int j = 2; i * j <= 1000; j++) pd[i * j] = false; p[++pp] = i; } for (int i = 1; i <= n; i++) scanf("%d",&a[i]); for (int i = 1; i <= n; i++) fa[i] = i; for (int i = 1; i <= n; i++){ for (int j = 1; j <= pp; j++){ if (a[i] % p[j] == 0){ while (a[i] % p[j] == 0) a[i] /= p[j]; if (Map[p[j]] == 0) Map[p[j]] = i; bin(Map[p[j]],i); } } if (a[i] != 1){ if (Map[a[i]] == 0) Map[a[i]] = i; bin(Map[a[i]],i); } } int ans = 1; // for (int i = 1; i <= n; i++) // printf(" %d\n",fa[i]); for (int i = 1; i <= n; i++) if (fa[i] == i){ ans = ans * 2 % mod; // printf("! %d\n",i); } printf("%d\n",(ans + mod - 2) % mod); } }