#include <bits/stdc++.h>
#define For(i,a,b) for ( int i=(a);i<=(b);i++ )
#define Dow(i,b,a) for ( int i=(b);i>=(a);i-- )
#define GO(i,x) for ( int i=head[x];i;i=e[i].nex )
#define mem(x,s) memset(x,s,sizeof(x))
#define cpy(x,s) memcpy(x,s,sizeof(x))
#define YES return puts("YES"),0
#define NO return puts("NO"),0
#define GG return puts("-1"),0
#define pb push_back
#define int long long
using namespace std;
inline int read()
{
int sum=0,ff=1; char ch=getchar();
while(!isdigit(ch))
{
if(ch=='-') ff=-1;
ch=getchar();
}
while(isdigit(ch))
sum=sum*10+(ch^48),ch=getchar();
return sum*ff;
}
const int mod=1e9+7;
const int mo=10086;
const int N=2e5+5;
int n,m,a[65],b[65],top,cnt,ans;
inline int ksm(int x,int y)
{
int z=1ll;
while(y)
{
if(y&1ll) z=z*x%mo;
x=x*x%mo;
y>>=1ll;
}
return z;
}
inline void insert(int x)
{
Dow(i,32,0) if(x&(1ll<<i-1))
{
if(!x) break;
if(!a[i])
{
a[i]=x;
break;
}
x^=a[i];
}
}
signed main()
{
n=read();
For(i,1,n)
{
int x=read();
insert(x);
}
m=read();
For(i,0,32) if(a[i]) b[++top]=i;
int sum=0;
For(i,1,top) if(m&(1ll<<b[i]-1)) sum=(sum+(1ll<<b[i]-1))%mo;
sum%=mo;
// cout<<sum<<endl;
printf("%lld\n",1ll*sum*ksm(2ll,n-top)%mo+1);
return 0;
}