# No.64 XORフィボナッチ数列 f0, f1, n = [int(i) for i in input().split()] if n % 3 == 0: print(f0) elif n % 3 == 1: print(f1) else: print(f0 ^ f1)