def main(): f0, f1, n = map(int, input().split()) fib = [f0, f1, f0 ^ f1] print(fib[n % 3]) if __name__ == '__main__': main()