import Data.Bits main=do [a,b,n]<-getLine>>=return.map (read::String->Integer).words print$[a,b,a`xor`b]!!(fromIntegral(n`mod`3))