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