#include <bits/stdc++.h>
#define rep(i,n) for (int i=0; i<(n); ++i)
using namespace std;
using ll=long long;

int main(){
    int n,m;
    cin>>n>>m;
    vector<int>to[100010];
    rep(i,m){
        int a,b; cin>>a>>b;
        a--; b--;
        to[a].push_back(b);
        to[b].push_back(a);
    }
    vector<int>dist(n,1e9);
    queue<int>q;
    q.push(0);
    dist[0]=0;
    while(!q.empty()){
        int v=q.front(); q.pop();
        for(int u:to[v]){
            if(dist[u]!=1e9)continue;
            dist[u]=v;
            q.push(u);
        }
    }
    cout<<"Yes"<<endl;
    for(int i=1; i<n; ++i){
        cout<<dist[i]+1<<endl;
    }
    return 0;
}