import qualified Data.Text as T
import qualified Data.Text.IO as T
import qualified Data.Text.Read as T
import qualified Data.Vector as V
import qualified Data.Vector.Unboxed as VU
import Data.IntSet (IntSet)
import qualified Data.IntSet as IS
import Data.Tuple (swap)

main :: IO ()
main = do
  [n, m] <- map unsafeTextToInt . T.words <$> T.getLine :: IO [Int]
  let
    parents :: [(Int, Int)] -> VU.Vector Int
    parents = VU.accum (flip const) (VU.replicate n n)
  abs <- sequence . replicate m $ unsafeListToPair . map (pred . unsafeTextToInt) . T.words <$> T.getLine :: IO [(Int, Int)]
  let
    edges = (++) <$> id <*> map swap $ abs :: [(Int, Int)]
    adjacency = fromEdgesToAdjacencyVectorN n edges :: V.Vector [Int]
    tree = fromAdjacencyVectorToSimpleGraph adjacency 0 :: Tree Int
    queue = (tree, n) : walk (pred n) (IS.singleton 0) queue :: [(Tree Int, Int)]
      where
        walk :: Int -> IntSet -> [(Tree Int, Int)] -> [(Tree Int, Int)]
        walk 0 _ _ = []
        walk l s (((Node i ts), _) : tps) = map (flip (,) i) ts' ++ walk (l - IS.size s') (IS.union s s') tps
          where
            ts' = filter (flip IS.notMember s . extract) ts :: [Tree Int]
            s' = IS.fromList . map extract $ ts' :: IntSet
  T.putStrLn . T.pack $ "Yes"
  VU.mapM_ print . VU.map succ . VU.tail . parents . map ((,) <$> extract . fst <*> snd) $ queue

fromEdgesToAdjacencyVectorN :: Int -> [(Int, Int)] -> V.Vector [Int]
fromEdgesToAdjacencyVectorN n = V.accum (flip (:)) (V.replicate n [])
{-# INLINE fromEdgesToAdjacencyVectorN #-}

fromAdjacencyVectorToSimpleGraph :: V.Vector [Int] -> Int -> Tree Int
fromAdjacencyVectorToSimpleGraph adjacency root = Node root (map (f root) (adjacency V.! root))
  where
    f :: Int -> Int -> Tree Int
    f p i = Node i (map (f i) . filter (/= p) $ adjacency V.! i)
{-# INLINE fromAdjacencyVectorToSimpleGraph #-}

data Tree a = Node a [Tree a]

extract :: Tree a -> a
extract (Node x _) = x

unsafeListToPair :: [Int] -> (Int, Int)
unsafeListToPair [x, y] = (x, y)
{-# INLINE unsafeListToPair #-}

unsafeTextToInt :: T.Text -> Int
unsafeTextToInt s = case T.signed T.decimal s of
  Right (n, _) -> n
{-# INLINE unsafeTextToInt #-}
