#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cstring>
#include <algorithm>
#include <set>
#include <map>
#include <queue>
#include <string>
#define LL long long
using namespace std;
const int maxN = 105;
const int MOD = 1000007;
int n, s[maxN];
void input()
{
scanf("%d", &n);
for (int i = 0; i < n; ++i)
scanf("%d", &s[i]);
}
//xor高斯消元求线性基
//时间复杂度O(30n)
int xorGauss(int n)
{
int row = 0;
for (int i = 30; i >= 0; i--)
{
int j;
for (j = row; j < n; j++)
if(s[j]&(1<<i))
break;
if (j != n)
{
swap(s[row], s[j]);
for (j = 0; j < n; j++)
{
if(j == row) continue;
if(s[j]&(1<<i))
s[j] ^= s[row];
}
row++;
}
}
return row;
}
void work()
{
int row, ans, k;
row = xorGauss(n);
ans = n-row;
if (ans != -1)
{
k = 1;
while (ans)
{
k <<= 1;
k %= MOD;
ans--;
}
ans = k;
}
else
ans = -1;
printf("%d
", ans);
}
int main()
{
//freopen("test.in", "r", stdin);
int T;
scanf("%d", &T);
for (int times = 0; times < T; ++times)
{
input();
work();
}
return 0;
}