f0, f1, n = map(int, input().split()) lst = [f1, f0^f1, f0] print(lst[(n-1)%3])