A,B,N=map(int,input().split()) if(N==0): print(A) elif(N==1): print(B) else: N-=1 for i in range(N): C=A^B B=A A=C print(A)