f = [0] * 3 f[0], f[1], N = map(int, input().split()) f[2] = f[0] ^ f[1] print(f[N%3])