n, k = map(int, input().split()) a = list(map(int, input().split())) for i in range(1000000): x = 0 for j in range(1, n + 1): x ^= a[-j] a.append(x) l = len(a) if l % 2 == 0 and a[-(l // 2):] == a[:(l // 2)]: break shuki = l // 2 print(a[(k - 1) % shuki])