import std.conv, std.stdio;
import std.algorithm, std.array, std.range, std.string;
import std.math;
void main()
{
    auto buf = readln.chomp.split.to!(size_t[]);
    immutable n = buf[0], m = buf[1];
    auto g = new size_t[][](n, 0);
    foreach (i; 0..m)
    {
        buf = readln.chomp.split.to!(size_t[]);
        g[buf[0] - 1] ~= buf[1] - 1;
        g[buf[1] - 1] ~= buf[0] - 1;
    }
    auto visited = new bool[n];
    auto answer = new size_t[n];
    size_t[] queue = [0];
    while (!queue.empty)
    {
        auto v = queue[0];
        queue = queue[1..$];
        foreach (next; g[v])
        {
            if (visited[next])
                continue;
            answer[next] = v;
            visited[next] = true;
            queue ~= next;
        }
    }
    if (!visited.all)
        return "No".writeln;
    "Yes".writeln;
    foreach (a; answer[1..$])
        (a + 1).writeln;
}
