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