A,B,N=map(int,input().split()) C=N%3 if C>1:O=A^B elif C>0:O=B else:O=A print(O)