F0,F1,N = map(int,input().split()) F2 = F0^F1 ls = [F0,F1,F2] print(ls[N%3])