f0,f1,n=list(map(int,input().split(" "))) stack=[f0,f1] stack.append(stack[len(stack)-2]^stack[len(stack)-1]) print(stack[n%3])