f0,f1,n = map(int, input().split(' ')) a = [f0, f1] for i in range(2, n+1): f1, f0 = f1^f0, f1 print(f0 if n == 0 else f1)