# coding: utf-8 # yukicoder No.64 XORフィボナッチ数列 ''' 状態遷移は f_2 = f_0 ^ f_1 とすると f_0, f_1, f_2, f_0, f_1, f_2, ... となるので、indexを3で割った余りが分かれば求まる ''' def fib_xor(f_0, f_1, n): f = [f_0, f_1, f_0 ^ f_1] return f[n % 3] f_0, f_1, n = map(int, input().split()) print(fib_xor(f_0, f_1, n))