f0,f1,n=map(int,input().split()) f=[f0,f1] for i in range(2,n+1): f_new=f[i-2]^f[i-1] f.append(f_new) #print(f) print(f[n])