//
#include
#include
#include
#include
#define maxn 110
using namespace std;
typedef int Int;
int T, N;
int beg[maxn], end[maxn], x[maxn];
int a[maxn][maxn];
int Gauss_XOR(Int a[maxn][maxn], Int x[maxn], int var, int equ)
{
int row, col;
for (row = col = 1; row <= equ && col <= var; ++row, ++col)
{
if (!a[row][col])
{
for (int i = equ; i > row; --i)
{
if (a[i][col])
{
for (int j = row; j <= var + 1; ++j)
{
swap(a[i][j], a[row][j]);
}
break;
}
}
}
if (!a[row][col])
{
--row;
continue;
}
for (int i = row + 1; i <= equ; ++i)
{
if (a[i][col])
{
for (int j = var + 1; j >= col; --j)
{
a[i][j] ^= a[row][j];
}
}
}
}
for (int i = row; i <= equ; ++i)
{
if (a[i][var + 1]) return -1;
}
if (row <= var)
{
return var - row + 1;
}
for (int i = var; i >= 1; --i)
{
x[i] = a[i][var + 1];
for (int j = i + 1; j <= var; ++j)
{
x[i] ^= a[i][j] && x[j];
}
}
return 0;
}
int main()
{
int num;
scanf("%d", &T);
while (T--)
{
int equ = 0;
memset(x, 0, sizeof (x));
memset(a, 0, sizeof (a));
scanf("%d", &N);
for(int i = 1; i <= N; ++i)
{
int pos = 1;
scanf("%d", &num);
while(num)
{
if(num & 1) a[pos][i] = 1;
else a[pos][i] = 0;
num >>= 1;
++pos;
}
equ = max(equ, pos - 1);
}
for(int i = 1; i <= 32; ++i)
a[i][N + 1] = 0;
int ans = Gauss_XOR(a, x, N, equ);
if (ans == -1) puts("-1");
else
{
int prt = 1;
for(int i = 1; i <= ans; ++i)
{
prt <<= 1;
prt %= 1000007;
}
printf("%d\n", prt);
}
}
return 0;
}