A, B, N = map(int, input().split()) if N%3 == 0: print(A) elif N%3 ==1: print(B) else: print(A^B)