import Control.Applicative ((<$>)) import Data.Bits (xor) main :: IO () main = do solve <$> getl (map read . words) >>= print solve :: [Int] -> Int solve [f0, f1, n] = case n `mod` 3 of 0 -> f0 1 -> f1 2 -> f1 `xor` f0 getl :: (String -> a) -> IO a getl f = f <$> getLine