import std;

alias Node = Tuple!(int, "val", int, "prev");

void calc(int n, int[][] adj) {

    auto used = new int[n];
    used[] = -1;

    auto q = DList!Node();
    q.insertBack(Node(0, 0));
    while (!q.empty) {
        auto node = q.front; q.removeFront();

        if (used[node.val] != -1) continue;
        used[node.val] = node.prev;

        foreach (e; adj[node.val]) {
            q.insertBack(Node(e, node.val));
        }
    }

    if (used.all!(e => e != -1)) {
        writeln("Yes");
        foreach (e; used[1..$]) writeln(e + 1);
    }
    else writeln("No");
}

void main() {
    int n, m; scan(n, m);
    int[][] adj;
    foreach (_; 0..n) adj ~= [[]];
    foreach (_; 0..m) {
        int a, b; scan(a, b);
        a--; b--;
        adj[a] ~= b;
        adj[b] ~= a;
    }
    calc(n, adj);
}

void scan(T...)(ref T a) {
    string[] ss = readln.split;
    foreach (i, t; T) a[i] = ss[i].to!t;
}
T read(T=string)() { return readln.chomp.to!T; }
T[] reads(T)() { return readln.split.to!(T[]); }
alias readints = reads!int;
