import std;

alias sread = () => readln.chomp();
alias lread = () => readln.chomp.to!long();
alias aryread(T = long) = () => readln.split.to!(T[]);
//aryread!string();
//auto PS = new Tuple!(long,string)[](M);
//x[]=1;でlong[]全要素1に初期化
void main()
{
    long n, m;
    scan(n, m);
    auto g = new long[][](n);
    // writeln(g);
    foreach (_; 0 .. m)
    {
        long a, b;
        scan(a, b);
        g[a - 1] ~= b - 1;
        g[b - 1] ~= a - 1;
    }
    // writeln(g);
    auto dist = new long[](n);
    dist[] = -1;
    // writeln(dist);
    DList!(long) que;
    dist[0] = 0;
    que.insertBack(0);
    // writeln(que);
    // foreach (x; que)
    // {
    //     writeln("que:", x);
    // }
    // foreach (nv; g[1])
    // {
    //     writeln("nv:", nv);
    //     writeln(dist[nv]);
    // }
    auto room_num = new long[](n);
    room_num[] = -1;
    while (!que.empty())
    {
        long v = que.front();
        que.removeFront();
        foreach (nv; g[v])
        {
            if (dist[nv] != -1)
            {
                continue;
            }
            dist[nv] = dist[v] + 1;
            room_num[nv] = v;
            que.insertBack(nv);
        }
    }
    if (func(room_num))
    {
        writeln("No");
        return;
    }
    else
    {
        writeln("Yes");
        foreach (v; 1 .. n)
        {
            writeln(room_num[v] + 1);

            // writeln(dist[v]);
        }
    }
}

auto func(long[] x)
{
    foreach (i; 1 .. (x.length))
    {
        if (x[i] != -1)
        {
            continue;
        }
        else
        {
            return true;
        }
    }
    return false;
}

void scan(L...)(ref L A)
{
    auto l = readln.split;
    foreach (i, T; L)
    {
        A[i] = l[i].to!T;
    }
}

void arywrite(T)(T a)
{
    a.map!text.join(' ').writeln;
}
