f0, f1, n = map(int,input().split()) f_list = [f0, f1, f0 ^ f1] res = f_list[n % 3] print(res)