import std;

ulong MAX = 100_100, MOD = 1_000_000_007, INF = 1_000_000_000_000;
alias sread = () => readln.chomp();
alias lread(T = long) = () => readln.chomp.to!(T);
alias aryread(T = long) = () => readln.split.to!(T[]);
alias Pair = Tuple!(long, "number", long, "cost");
alias PQueue(T, alias less = "a>b") = BinaryHeap!(Array!T, less);

void main()
{
    long n, m;
    scan(n, m);
    auto route = new long[][](n, 0);
    foreach (_; iota(m))
    {
        long a, b;
        scan(a, b);
        route[a - 1] ~= b - 1;
        route[b - 1] ~= a - 1;
    }
    auto mincost = new long[](n);
    mincost[] = INF;

    void bfs()
    {
        auto q = DList!(Pair)(Pair(0, 0));
        while (!q.empty())
        {
            auto f = q.front();
            q.removeFront();
            mincost[f.number] = min(mincost[f.number], f.cost);
            foreach (e; route[f.number])
            {
                if (mincost[e] == INF)
                    q.insertBack(Pair(e, f.number));
            }
        }
    }

    bfs();
    writeln("Yes");
    mincost[1 .. $].each!(x => writeln(x + 1));
}

void scan(TList...)(ref TList Args)
{
    auto line = readln.split();
    foreach (i, T; TList)
    {
        T val = line[i].to!(T);
        Args[i] = val;
    }
}
