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