I=input N,M,K=map(int,I().split()) S=[int(I(),2)for i in range(M)] i=j=0 while i>j&1<1:k+=1 if k>j&1:S[k]^=S[i-1] k+=1 j+=1 print(1<<(N-i)%K)