import Control.Monad (replicateM) import Data.List main = do [n, m] <- getInts r <- judge . concat <$> replicateM m getInts putStrLn (yesno r) getInts :: IO [Int] getInts = map read . words <$> getLine judge :: [Int] -> Bool judge = (\x -> x == 0 || x == 2) . count odd . map length . group . sort count :: (a -> Bool) -> [a] -> Int count p = length . filter p yesno :: Bool -> String yesno True = "YES" yesno False = "NO"