F0,F1,N=map(int,input().split()) F2=0 if N==0: print(F0) if N==1: print(F1) for i in range(N-1): F2=F1^F0;F0=F1;F1=F2 print(F2)