x, y, n = map(int, input().split()) n %= 3 if n == 0: print(x) elif n == 1: print(y) else: print(x ^ y)