f,g,n = map(int,input().split()) for i in range(n%3): f,g = g,f^g print(f)