import Control.Monad
import Data.Maybe
import qualified Data.ByteString.Char8 as BS
import Data.List
import qualified Data.Vector as V
import qualified Data.Vector.Mutable as VM
import qualified Data.Vector.Unboxed as VU
import qualified Data.Vector.Unboxed.Mutable as VUM

readInt = fst . fromJust . BS.readInt
readIntList = map readInt . BS.words
getInt = readInt <$> BS.getLine
getIntList = readIntList <$> BS.getLine

main = do
    [n,m] <- getIntList
    ab <- VU.replicateM m $ do
        [a,b] <- getIntList
        return (a-1,b-1)
    let edge = V.create $ do
                vec <- VM.replicate n []
                VU.forM_ ab $ \(a,b) -> do
                    VM.modify vec (a:) b
                    VM.modify vec (b:) a
                return vec
    let result = VU.create $ do
                vec <- VUM.replicate n (-1 :: Int)
                let bfs [] = return ()
                    bfs ((this,k):qs) = do
                        d <- VUM.read vec this
                        when (d < 0) $ VUM.write vec this k
                        nexts <- flip zip [k+1,k+1..] <$> filterM (\a -> fmap (< 0) (VUM.read vec a)) (edge V.! this)
                        bfs (qs++nexts)
                bfs [(0,0)]
                return vec
    putStrLn "Yes"
    VU.mapM_ print $ VU.drop 1 result