def main(): f_0, f_1, n = [int(i) for i in input().split()] if n % 3 == 0: ans = f_0 elif n % 3 == 1: ans = f_1 elif n % 3 == 2: ans = f_0 ^ f_1 print(ans) if __name__ == "__main__": main()