{-# LANGUAGE MultiWayIf #-}
{-# LANGUAGE BangPatterns #-}


import qualified Data.Vector.Unboxed as U
import qualified Data.Vector.Unboxed.Mutable as UM
import qualified Data.ByteString.Char8 as C
import Data.List
import Control.Monad
import Control.Arrow
import qualified Data.IntMap.Strict as IM
import qualified Data.Sequence as Sq
import Control.Concurrent


r :: Int -> IO (U.Vector Int)
r n = U.unfoldrN n (C.readInt . C.dropWhile (==' ')) <$> C.getLine

r' :: IO [Int]
r'  =   unfoldr    (C.readInt . C.dropWhile (==' ')) <$> C.getLine



insertIMapSq key el = IM.insertWith (Sq.><) key (Sq.singleton el)

main = do
    [n,m] <- r'

    ways <- replicateM m r'

    let im = foldr (\[a,b] mp -> insertIMapSq b a (insertIMapSq a b mp) ) IM.empty ways

    answer  <- U.thaw $ U.replicate (n+2) ((-1) :: Int)
    UM.write answer 1 0

    bfs (Sq.fromList [1]) im answer
    ans <- U.freeze answer

    putStrLn "Yes" -- ?
    U.mapM_ print $ U.take (n-1) $ U.drop 2 ans

bfs :: Sq.Seq Int -> IM.IntMap (Sq.Seq Int) -> UM.IOVector Int -> IO ()
bfs Sq.Empty _ _ = return ()
bfs (h Sq.:<| sq) imap answer = do
    ans <- U.freeze answer

    let children = imap IM.! h

    xs <- traverse (\a -> do
        b <- UM.read answer a
        return (b<0,a)) children
    let nextBFS = fmap snd $ Sq.filter fst xs

    mapM_ (\c -> UM.write answer c h) nextBFS

    bfs (sq Sq.>< nextBFS) imap answer