F0, F1, N = map(int, input().split()) fib = [F0, F1] for _ in range(N - 1): fib.append(fib[-2] ^ fib[-1]) print(fib[N])