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