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