N,K = map(int,input().split()) A = list(map(int,input().split())) def matmul(X,Y): Z = [[0 for _ in range(N)] for _ in range(N)] for i in range(N): for j in range(N): for k in range(N): Z[i][j] = Z[i][j]^(X[i][k]*Y[k][j]) return Z I = [[0 for _ in range(N)] for _ in range(N)] for i in range(N): for j in range(N): if i==j: I[i][j] = 1 def matpow(X,k): if k==0: return I if k==1: return X if k%2==0: return matmul(matpow(X,k//2),matpow(X,k//2)) Y = matmul(matpow(X,(k-1)//2),matpow(X,(k-1)//2)) return matmul(X,Y) T = N+1 M = (K-1)%T A1 = [[0 for _ in range(N)] for _ in range(N)] for i in range(N-1): A1[i][i+1] = 1 for j in range(N): A1[N-1][j] = 1 B = matpow(A1,M) ans = 0 for i in range(N): ans = ans^(B[0][i]*A[i]) print(ans)