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