f,g,N=map(int,input().split()) print(f if N%3==0 else g if N%3==1 else g^f)