F_0,F_1,n=map(int,input().split()) F_2=F_0^F_1 if n%3==0: print(F_0) elif n%3==1: print(F_1) else: print(F_2)