import sys read = sys.stdin.buffer.read readline = sys.stdin.buffer.readline readlines = sys.stdin.buffer.readlines a,b,n = map(int,read().split()) F = [a,b,a^b] answer = F[n%3] print(answer)