def main(): N,K = map(int,input().split()) A = list(map(int,input().split())) v = 0 for i in range(N): v ^= A[i] A.append(v) #print(A) if K%(N+1) == 0: ans = A[-1] else: ans = A[(K-1)%(N+1)] print(ans) if __name__ == '__main__': main()