A,B,N=map(int,input().split()) F=[A,B] for i in range(2,N+1): F.append(F[-1]^F[-2]) print(F[N])