A, B, N = [int(i) for i in input().split()] print([A, B, A ^ B][N % 3])