#include <bits/stdc++.h>
using namespace std;
int main()
{
    int n, m;
    cin >> n >> m;
    vector<vector<int>> g(n);
    for(int i = 0; i < m; i++)
    {
        int a, b;
        cin >> a >> b;
        a--,b--;
        g[a].push_back(b);
        g[b].push_back(a);
    }
    vector<int> ans(n, -1);
    queue<int> que;
    que.push(0);
    while(!que.empty())
    {
        int v = que.front();
        que.pop();
        for(int nx : g[v])
        {
            if(nx == 0 || ans[nx] != -1) continue;
            ans[nx] = v;
            que.push(nx);
        }
    }
    cout << "Yes" << endl;
    for(int i = 1; i < n; i++) cout << ans[i] + 1 << endl;
}
