f0, f1, n = map(int, input().split()) f = [f0, f1] f.append(f0 ^ f1) print(f[n % 3])