a,b,n=map(int,input().split()) f2=a^b if n%3==0: print(a) elif n%3==1: print(b) else: print(f2)