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