F0, F1, N = map(int, input().split()) F2 = F0 ^ F1 if N % 3 == 2: print(F2) elif N % 3 == 1: print(F1) else: print(F0)