f = [0] * 3 f[0], f[1], N = map(int, input().split()) for i in range(2, N+1): f[2] = f[0] ^ f[1] f[0], f[1], = f[1], f[2] print(f[N%3])