a,b,N = map(int,raw_input().split()) if N % 3 == 0: print a elif N % 3 == 1: print b else: print a^b