import Control.Monad
import Control.Monad.Primitive
import qualified Data.ByteString.Char8 as BS
import Data.List
import Data.Maybe
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

getIntList = readIntList <$> BS.getLine

getIntNList n = map readIntList <$> replicateM (fromIntegral n) BS.getLine

paint :: VUM.IOVector Int -> [(Int, Int)] -> IO ()
paint table (t : ts) = do
  let f = fst t
  let s = snd t
  p <- VUM.read table s
  when (p == 0) $ VUM.write table s f
  when (ts /= []) $ paint table ts

part :: [[Int]] -> [Int] -> [(Int, Int)] -> [[Int]] -> [Int] -> ([(Int, Int)], [[Int]], [Int])
part (ab : abs) is xs ys js = do
  let h = head ab
  let l = last ab
  let (xs', ys', js')
        | elem h is = (((h, l) : xs), ys, (l : js))
        | elem l is = (((l, h) : xs), ys, (h : js))
        | otherwise = (xs, (ab : ys), js)
  if abs /= []
    then part abs is xs' ys' js'
    else (xs', ys', js')

padding :: VUM.IOVector Int -> [[Int]] -> [Int] -> IO ()
padding table abs is = do
  let (xs, ys, js) = part abs is [] [] []
  paint table xs
  t <- VU.freeze table
  let t' = VU.tail (VU.tail t)
  when (ys /= [] && VU.any (== 0) t') $ padding table ys js

main = do
  [n, m] <- getIntList
  abs <- getIntNList m
  table <- VUM.replicate (n + 1) 0 :: IO (VUM.IOVector Int)
  VUM.write table 1 1
  padding table abs [1]
  t <- VU.freeze table
  let t' = VU.tail (VU.tail t)
  if VU.length (VU.filter (== 0) t') /= 0
    then putStrLn "No"
    else do
      putStrLn "Yes"
      VU.mapM_ print t'
