F0, F1, N = [int(i) for i in input().strip().split(' ')] print([F0, F1, F0 ^ F1][N % 3])