a,b,N = map(int,raw_input().split()) count = 0 stack = [] stack.append(b) stack.append(a) while N>count: B = stack.pop() A = stack.pop() stack.append(A^B) stack.append(A) count += 1 print stack.pop()