x,y,n = map(int,input().split()) z = x^y if n%3 == 0: print(x) elif n%3 == 1: print(y) else: print(z)