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