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