f0,f1,n=map(int,input().split()) r=n%3 print(f0 if r==0 else f1 if r==1 else f0^f1)