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