#include<bits/stdc++.h>
using namespace std;
void Solve(){
int n, m;
cin>>n>>m;
vector<int> g[n + 1];
while(m--){
int u, v;
cin>>u>>v;
g[u].push_back(v);
g[v].push_back(u);
}
vector<bool> vst(n + 1);
queue<int> q;
vector<int> res(n + 1);
q.push(1);
vst[1] = true;
while(!q.empty()){
int current = q.front();
q.pop();
for(auto x: g[current]){
if(!vst[x]){
vst[x] = true;
q.push(x);
res[x] = current;
}
}
}
cout<<"Yes\n";
for(int i = 2; i <= n; i++) cout<<res[i]<<'\n';
}
int main(){
ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
int T = 1;
//cin>>T;
while(T--){
Solve();
}
}
I2luY2x1ZGU8Yml0cy9zdGRjKysuaD4KIAp1c2luZyBuYW1lc3BhY2Ugc3RkOwoKdm9pZCBTb2x2ZSgpewoJaW50IG4sIG07CgljaW4+Pm4+Pm07Cgl2ZWN0b3I8aW50PiBnW24gKyAxXTsKCXdoaWxlKG0tLSl7CgkJaW50IHUsIHY7CgkJY2luPj51Pj52OwoJCWdbdV0ucHVzaF9iYWNrKHYpOwoJCWdbdl0ucHVzaF9iYWNrKHUpOwoJfQoJdmVjdG9yPGJvb2w+IHZzdChuICsgMSk7CglxdWV1ZTxpbnQ+IHE7Cgl2ZWN0b3I8aW50PiByZXMobiArIDEpOwoJcS5wdXNoKDEpOwoJdnN0WzFdID0gdHJ1ZTsKCXdoaWxlKCFxLmVtcHR5KCkpewoJCWludCBjdXJyZW50ID0gcS5mcm9udCgpOwoJCXEucG9wKCk7CgkJZm9yKGF1dG8geDogZ1tjdXJyZW50XSl7CgkJCWlmKCF2c3RbeF0pewoJCQkJdnN0W3hdID0gdHJ1ZTsKCQkJCXEucHVzaCh4KTsKCQkJCXJlc1t4XSA9IGN1cnJlbnQ7CgkJCX0KCQl9Cgl9Cgljb3V0PDwiWWVzXG4iOwoJZm9yKGludCBpID0gMjsgaSA8PSBuOyBpKyspIGNvdXQ8PHJlc1tpXTw8J1xuJzsKfQppbnQgbWFpbigpewoJaW9zX2Jhc2U6OnN5bmNfd2l0aF9zdGRpbygwKTsgY2luLnRpZSgwKTsgY291dC50aWUoMCk7CglpbnQgVCA9IDE7CgkvL2Npbj4+VDsKCXdoaWxlKFQtLSl7CgkJU29sdmUoKTsKCX0KfQ==