f = [0] * 3 f[0], f[1], n = [int(x) for x in input().split()] f[2] = f[1] ^ f[0] res = f[n % 3] print(res)