def main(): f_0, f_1, n = [int(i) for i in input().split()] sequence_list = [f_0, f_1] for i in range(2, n + 1): sequence_list.append(sequence_list[i - 2] ^ sequence_list[i - 1]) print(sequence_list[n]) if __name__ == "__main__": main()