from operator import xor f0,f1,N =map(int,input().split()) if N % 3 == 0 : print(f0) elif N % 3 == 1 : print(f1) else : print(xor(f0, f1))