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