F0, F1, N = map(int, input().split()) f = [] f.append(F0) f.append(F1) f.append(F0 ^ F1) print(f[N%3])