#include <bits/stdc++.h>
#define int long long
using namespace std;

signed 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);
    }
    queue<int> que;
    que.push(0);
    vector<int> ans(N,-1);
    ans[0]=0;
    while(!que.empty()){
        int v=que.front();
        que.pop();
        for(auto nv : G[v]){
            if(ans[nv]!=-1)continue;
            ans[nv]=v+1;
            que.push(nv);
        }
    }
    cout<<"Yes"<<endl;
    for(int i=1;i<N;i++)cout<<ans[i]<<endl;
    return 0;
}