A,B,N=map(int,input().split()) N%=3 if(N==0): print(A) elif(N==1): print(B) else: print(A^B)