import Control.Monad import Data.Graph import Data.Bool import Data.Tuple import Data.List import Data.Array import qualified Data.ByteString.Char8 as B main :: IO () main = solve <$> (fst . pairs <$> B.getLine) <*> (map pairs . B.lines <$> B.getContents) >>= putStrLn . bool "NO" "YES" pairs :: B.ByteString -> (Int, Int) pairs = (\[x, y] -> (x, y)) . map (maybe undefined fst . B.readInt) . B.words solve :: Int -> [(Int, Int)] -> Bool solve n es | numOdd == 0 || numOdd == 2 = (length . bcc) g <= 1 | otherwise = False where g = buildG (0, n - 1) (es ++ map swap es) numOdd = length . filter odd . elems . outdegree $ g