def fib(a,b,n): if n==0: data[0]=a return data[0] if n==1: data[1]=b return data[1] if data[n]!=-1: return data[n] data[n]=fib(a,b,n-1)^fib(a,b,n-2) return fib(a,b,n-1)^fib(a,b,n-2) a,b,n = map(int,input().split()) data=[-1]*(n+1) ans=fib(a,b,n) print(ans)