import Data.Bits rInteger :: String -> Integer rInteger = read main = getLine >>= print . f . map rInteger . words where f [f0,f1,n] | n' == 0 = f0 | n' == 1 = f1 | otherwise = f0 `xor` f1 where n' = n `mod` 3