def main(): F0, F1 , N = map(int, input().split()) F2 = F0 ^ F1 print([F0, F1, F2][N % 3]) if __name__ == "__main__": main()