{-# OPTIONS_GHC -Wno-unused-imports -Wno-unused-top-binds #-} import Control.Monad import Data.Maybe import qualified Data.ByteString.Char8 as BS import Control.Monad.ST import Data.Ix import Data.Array (Array) import Data.Array.IArray import Data.Array.IO import Data.Array.MArray import Data.Array.ST import Data.Array.Unboxed (UArray) import Data.Char import Data.List as L import Data.Foldable import Data.Function import Control.Exception import Data.Array.Base (STUArray(STUArray), UArray (UArray)) import Data.Array.IO.Internals (IOUArray(IOUArray)) import Data.Ord import GHC.Float one = ["gray","brown","green","cyan","blue","yellow","orange","red"] two = ["gray","green","blue","yellow","red"] thr = ["gray","green","cyan","blue","violet","orange","red"] ps :: [[Int]] ps = permutations [1, 2, 3] look :: String -> Int -> Bool look s 1 = s `elem` one look s 2 = s `elem` two look s 3 = s `elem` thr main :: IO () main = do ss <- words <$> getLine let zss = map (and . zipWith look ss) ps l = length $ filter id zss bl = length (nubOrd ss) == 1 || l == 1 yn bl --library-------------- modulus :: Int modulus = 10 ^ 9 + 7 addMod, subMod, mulMod :: Int -> Int -> Int addMod x y = (x + y) `mod` modulus subMod x y = (x - y) `mod` modulus mulMod x y = (x * y) `mod` modulus tuplify2 :: [b] -> (b, b) tuplify2 (x:y:_) = (x,y) tuplify2 _ = undefined readInt :: BS.ByteString -> Int readInt = fst . fromJust . BS.readInt readIntTuple :: BS.ByteString -> (Int, Int) readIntTuple = tuplify2 . map readInt . BS.words readIntList :: BS.ByteString -> [Int] readIntList = map readInt . BS.words getInt :: IO Int getInt = readInt <$> BS.getLine getIntList :: IO [Int] getIntList = readIntList <$> BS.getLine getIntListX :: IO [Int] getIntListX = readIntList <$> BS.getContents getIntNList :: Integral a => a -> IO [[Int]] getIntNList n = map readIntList <$> replicateM (fromIntegral n) BS.getLine getIntMatrix :: IO [[Int]] getIntMatrix = map readIntList . BS.lines <$> BS.getContents getIntTuple :: IO (Int, Int) getIntTuple = readIntTuple <$> BS.getLine getIntNTuples :: Integral a => a -> IO [(Int, Int)] getIntNTuples n = map readIntTuple <$> replicateM (fromIntegral n) BS.getLine getIntTuples :: IO [(Int, Int)] getIntTuples = map readIntTuple . BS.lines <$> BS.getContents getIntMatArr :: Int -> Int -> IO (UArray (Int, Int) Int) getIntMatArr h w = listArray ((1, 1), (h, w)) . concat <$> getIntNList h yn :: Bool -> IO () yn bl = putStrLn $ if bl then "Yes" else "No" putInts :: [Int] -> IO () putInts x = putStrLn $ unwords $ map show x nubOrd :: Eq a => Ord a => [a] -> [a] nubOrd = map head.group.sort