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