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