At the beginning of the game they pick N (1<=N<=100) piles of stones, Mr.Frost and his friend move the stones in turn. At each step of the game, the player chooses a pile, removes at least one stone from the pile, the first player can’t make a move, and loses. So smart is the friends of Mr.Frost that Mr.Frost always loses. Having been a loser for too many times, he wants to play a trick. His plan is to remove some piles, and then he can find a way to make sure that he would be the winner after his friends remove stones first.
Now, he wants to know how many ways to remove piles which are able to achieve his purpose. If it’s impossible to find any way, please print “-1”.
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<vector>
#include<string>
#include<iostream>
#include<queue>
#include<cmath>
#include<map>
#include<stack>
#include<set>
using namespace std;
#define REPF( i , a , b ) for ( int i = a ; i <= b ; ++ i )
#define REP( i , n ) for ( int i = 0 ; i < n ; ++ i )
#define CLEAR( a , x ) memset ( a , x , sizeof a )
const int INF=0x3f3f3f3f;
typedef long long LL;
const int mod=1000007;
int t,mp[35][110],n;
int A[110];
int equ,var;
int X[55],free_x[55];
int free_num;
int Gauss()
{
int max_r,col,k;
free_num=0;
for(k=0,col=0;k<equ&&col<var;k++,col++)
{
max_r=k;
for(int i=k+1;i<equ;i++)
{
if(abs(mp[i][col])>abs(mp[max_r][col]))
max_r=i;
}
if(mp[max_r][col]==0)
{
k--;
free_x[free_num++]=col;
continue;
}
if(max_r!=k)
{
for(int j=col;j<var+1;j++)
swap(mp[k][j],mp[max_r][j]);
}
for(int i=k+1;i<equ;i++)
{
if(mp[i][col]!=0)
{
for(int j=col;j<var+1;j++)
mp[i][j]^=mp[k][j];
}
}
}
for(int i=k;i<equ;i++)
if(mp[i][col]!=0) return -1;
return var-k;
}
int main()
{
scanf("%d",&t);
while(t--)
{
scanf("%d",&n);
CLEAR(mp,0);
for(int i=0;i<n;i++)
scanf("%d",&A[i]);
for(int i=0;i<31;i++)
{
for(int j=0;j<n;j++)
{
if(A[j]&(1<<i))
mp[i][j]=1;
}
}
equ=31;var=n;
int ans=Gauss();
if(ans==-1)
{
puts("0");
continue;
}
LL sum=1;
//cout<<"fuck "<<ans<<endl;
for(int i=0;i<ans;i++)
sum=sum*2LL%mod;
printf("%lld\n",sum);
}
return 0;
}