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