a,b,n=map(int,input().split()) def Fib(n): global a global b 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))