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