f0, f1, N = map(int, input().split()) F = [f0, f1] for _ in range(3): F.append(F[-1]^F[-2]) print(F[(N-2)%3+2]) if N > 1 else print(F[N])