A,B,N = map(int, input().split()) print([A,B,A^B][N%3])