#![allow(unused, non_snake_case, dead_code, non_upper_case_globals)]
#![macro_use]

use std::cmp::*;
use std::collections::*;
use std::io::*;
use std::mem::*;
use std::num::*;
use std::slice::*;

fn main() {
    let (r, w, e) = (stdin(), stdout(), stderr());
    let mut io = IO::new(r.lock(), w.lock(), e.lock());
    // =============================================== //
    let (n, m): (usize, usize) = (io.read(), io.read());
    let mut g: Vec<Vec<usize>> = vec![Vec::new(); n];
    for _ in 0..m {
        let (a, b): (usize, usize) = (io.read(), io.read());
        g[a - 1].push(b - 1);
        g[b - 1].push(a - 1);
    }
    //let inf = 5 << 40;
    // let ans: Vec<(usize, usize)> = vec![(inf, 0); n];
    // let mut gg: G = G { g: g, ans: ans };
    // gg.dfs(0, 0, 0);
    // //io.debug(gg.ans)
    // let ans = gg.ans;
    // println!("Yes");
    // for i in 1..n {
    //     println!("{}", ans[i].1 + 1);
    // }

    let mut q: VecDeque<(usize, usize, usize)> = VecDeque::new();
    let mut ans: Vec<isize> = vec![0; n];
    q.push_back((0, 0, 0));
    ans[0] = 0;
    let mut visited = vec![false; n];
    visited[0] = true;
    let inf = 5 << 50;
    let mut ans2: Vec<(usize, usize)> = vec![(inf, 0); n];
    // bfs
    while let Some(got) = q.pop_front() {
        //
        let now = got.0;
        let depth = got.1;
        let prev = got.2;
        visited[now] = true;
        //ans2[now] = min(ans2[now], (depth, prev));
        if ans2[now].0 > depth {
            ans2[now] = (depth, prev);
        }
        ans[now] = prev as isize;

        for &nxt in g[now].iter() {
            if visited[nxt] {
                continue;
            }
            //   println!("now = {}, nxt = {}, depth = {}", now + 1, nxt + 1, depth);
            //visited[nxt] = true;
            q.push_back((nxt, depth + 1, now));
            visited[nxt] = true;
        }
    }
    println!("Yes");
    for i in 1..n {
        println!("{}", ans2[i].1 + 1);
    }
}
// struct G {
//     g: Vec<Vec<usize>>,
//     ans: Vec<(usize, usize)>,
// }
// impl G {
//     fn dfs(&mut self, depth: usize, now: usize, prev: usize) {
//         if self.ans[now].0 > depth {
//             self.ans[now].0 = depth;
//             self.ans[now].1 = prev;
//         } else {
//             return;
//         }

//         let len = self.g[now].len();
//         //println!("{}", len);
//         for i in 0..len {
//             if (self.g[now][i] != prev) {
//                 self.dfs(depth + 1, self.g[now][i], now);
//             }
//         }
//     }
// }

// IO
struct IO<R: Read, W: Write, E: Write> {
    Read: R,
    Write: BufWriter<W>,
    Error: BufWriter<E>,
}
impl<R: Read, W: Write, E: Write> IO<R, W, E> {
    fn new(r: R, w: W, e: E) -> IO<R, W, E> {
        IO {
            Read: r,
            Write: BufWriter::new(w),
            Error: BufWriter::new(e),
        }
    }
    fn read<T>(&mut self) -> T
    where
        T: std::str::FromStr,
    {
        let next: String = self
            .Read
            .by_ref()
            .bytes()
            .map(|c| c.unwrap() as char)
            .skip_while(|c| c.is_whitespace())
            .take_while(|c| !c.is_whitespace())
            .collect();
        next.parse().ok().unwrap()
    }
    fn chars(&mut self) -> Vec<char> {
        self.read::<String>().chars().collect()
    }
    fn readn<T: std::str::FromStr>(&mut self, n: usize) -> Vec<T> {
        (0..n).map(|_| self.read::<T>()).collect::<Vec<_>>()
    }
    fn readmat<T: std::str::FromStr>(&mut self, n: usize, m: usize) -> Vec<Vec<T>> {
        (0..n).map(|_| self.readn(m)).collect()
    }
    fn write<S: ToString>(&mut self, val: S) {
        self.Write.write(val.to_string().as_bytes());
    }
    fn writeln<S: ToString>(&mut self, val: S) {
        self.Write.write(val.to_string().as_bytes());
        self.Write.write(b"\n");
    }
    fn debug<S: std::fmt::Debug>(&mut self, val: S) {
        writeln!(self.Error, "(debug ) {:?}", &val);
    }
    fn debug2<S: std::fmt::Debug, T: std::fmt::Debug>(&mut self, val1: S, val2: T) {
        writeln!(self.Error, "(debug2) {:?} -> {:?}", val1, val2);
    }
}


Measured memory_bytes: 15092