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