a,b,c=map(int,input().split()) f=[a,b] for i in range(2,100+1): f.append(f[i-1]^f[i-2]) print(f[c%3])