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