F0, F1, N = map(int, input().split()) F = [F0, F1] + [0] * (N-1) for i in range(N-1): F[i+2] = F[i+1] ^ F[i] print(F[N])