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