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