F0, F1, N = map(int, input().split()) if N==0: print(F0) exit() if N==1: print(F1) exit() N %= 3 N -= 1 F = [F0, F1] for i in range(N): F.append(F[-1]^F[-2]) print(F[-1])