F0,F1,N=map(int,input().split()) #print(F0,F1,N) if N==0:print(F0) elif N==1:print(F1) elif N==2:print(F0^F1) else: for i in range(2,N+1): F=F0^F1 F0,F1=F1,F print(F)