def Fib(n): a,b,n=map(int,input().split()) if n == 0: return a elif n == 1: return b else: for i in range(n-1): a, b = b, a^b return b print(Fib(n))