f = [0,0,0] f[0],f[1],n = map(int,input().split()) f[2] = f[0]^f[1] print(f[n%3])