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

int main(){
    int n,m;
    cin>>n>>m;
    vector<int> to[100100];
    rep(i,m){
        int a,b;
        cin>>a>>b;
        --a;--b;
        to[a].push_back(b);
        to[b].push_back(a);
    }

    queue<int> q;
    vector<int> dist(n, INF);
    vector<int> pre(n, -1);
    q.push(0);
    dist[0]=0;

    while(!q.empty()){
        int v = q.front(); q.pop();
        for(int u: to[v]){
            if(dist[u]!=INF)continue;
            dist[u]=dist[v]+1;
            pre[u]=v;
            q.push(u);
        }
    }
    cout<<"Yes"<<endl;
    rep(i,n){
        if(i==0)continue;
        cout<<pre[i]+1<<endl;
    }
    return 0;

}