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