F = [0]*3 (F[0], F[1], N) = map(int, input().split()) F[2] = F[0] ^ F[1] print(F[N%3])