F0, F1, N = [int(i) for i in input().split()] F2 = F0 ^ F1 if N % 3 == 0: print(F0) if N % 3 == 1: print(F1) if N % 3 == 2: print(F2)