#include<bits/stdc++.h>
using namespace std;
vector<int> adj[100001];
bool visited[100001];
int ans[100001];
void bfs()
{
queue<pair<int,int> > q;
//pair<int,int> p = make_pair(1,1);
ans[1] = 1;
q.push({1,1});
while(!q.empty())
{
pair<int,int> p = q.front();
q.pop();
visited[p.first] = true;
ans[p.first] = p.second;
for(int i=0;i<adj[p.first].size();i++)
{
p = make_pair(adj[p.first][i],p.first);
if(visited[p.first] == false)
q.push(p);
}
}
}
int main()
{
memset(visited,false,sizeof(visited));
memset(ans,0,sizeof(ans));
int nodes,edges;
cin >> nodes >> edges;
for(int i=0;i<edges;i++)
{
int u,v;
cin >> u >> v;
adj[u].push_back(v);
adj[v].push_back(u);
}
bfs();
cout << "Yes\n";
for(int i=2;i<=nodes;i++)
cout << ans[i] << "\n";
}
I2luY2x1ZGU8Yml0cy9zdGRjKysuaD4KdXNpbmcgbmFtZXNwYWNlIHN0ZDsKdmVjdG9yPGludD4gYWRqWzEwMDAwMV07CmJvb2wgdmlzaXRlZFsxMDAwMDFdOwppbnQgYW5zWzEwMDAwMV07CnZvaWQgYmZzKCkKewoJcXVldWU8cGFpcjxpbnQsaW50PiA+IHE7CgkvL3BhaXI8aW50LGludD4gcCA9IG1ha2VfcGFpcigxLDEpOwoJYW5zWzFdID0gMTsKCXEucHVzaCh7MSwxfSk7Cgl3aGlsZSghcS5lbXB0eSgpKQoJewoJCXBhaXI8aW50LGludD4gcCA9IHEuZnJvbnQoKTsKCQlxLnBvcCgpOwoJCXZpc2l0ZWRbcC5maXJzdF0gPSB0cnVlOwoJCWFuc1twLmZpcnN0XSA9IHAuc2Vjb25kOwoJCWZvcihpbnQgaT0wO2k8YWRqW3AuZmlyc3RdLnNpemUoKTtpKyspCgkJewoJCQlwID0gbWFrZV9wYWlyKGFkaltwLmZpcnN0XVtpXSxwLmZpcnN0KTsKCQkJaWYodmlzaXRlZFtwLmZpcnN0XSA9PSBmYWxzZSkKCQkJCXEucHVzaChwKTsKCQl9Cgl9Cn0KaW50IG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