n,m,k = map(int,input().split()) a = [int(i) for i in input().split()] b = [int(i) for i in input().split()] mod = 10**9+7 ngs = 1024#1024 arui = [0]*(ngs) arui[0] = 1 ali = [0]*(ngs) for i in range(n): narui = [0]*ngs narui[0] = 1 for j in range(ngs): narui[j^a[i]] += arui[j] #narui[j^a[i]] %= mod arui = narui[:] for j in range(ngs): if j == 0: ali[j] += arui[j]-1 else: ali[j] += arui[j] #ali[j] %= mod brui = [0]*(ngs) brui[0] = 1 bli = [0]*(ngs) for i in range(m): nbrui = [0]*ngs nbrui[0] = 1 for j in range(ngs): nbrui[j^b[i]] += brui[j] #nbrui[j^b[i]] %= mod brui = nbrui[:] for j in range(ngs): if j == 0: bli[j] += brui[j]-1 else: bli[j] += brui[j] #bli[j] %= mod #print(ali,bli) #exit() ans = 0 for i in range(ngs): ans += ali[i]*bli[i^k] ans %= mod print(ans)