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