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