l0,l1,n=map(int,input().split()) if n<2: print([l0,l1][n]) else: for i in range(2,n+1): l=l0^l1 l0=l1 l1=l print(l)