F1,F2,K = map(int,input().split()) if K%3==0: print(F1) elif K%3==1: print(F2) else: print(F1^F2)