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