// Slower C++ solution:
#include <bits/stdc++.h>

#include <ext/pb_ds/assoc_container.hpp> // Common file

#include <ext/pb_ds/tree_policy.hpp>

#define sz(v)   ((int)(v).size())

#define  all(v)    ((v).begin()),((v).end())

#define  allr(v)    ((v).rbegin()),((v).rend())

#define   pb         push_back

#define   mp         make_pair

#define    Lcm(a,b)  ((a*b)/(__gcd(a,b)))

#define    clr(v,d)      memset( v, d ,sizeof(v))

#define    PI            acos(-1)

typedef  long long     ll ;

typedef  unsigned long long     ull ;

const long double eps= (1e-9);

using namespace std;

using namespace __gnu_pbds;

int dcmp(long double a,long double b){   return fabsl(a-b)<=eps ? 0: (a>b)? 1:-1  ;}

void GO(){ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);}

const int N=100000+9;

vector< vector<int> > v(N);

int vis[N],par[N],dist[N],ass[N];

void bfs(int src){



  queue<int> q;

  q.push(src);

  vis[src]=1;

  dist[src]=0;

  par[src]=-1;

  int lv=-1;

  while(sz(q)>0){

    int siz=sz(q);

    lv++;

    while(siz--){



        int cur=q.front();

        q.pop();

        dist[cur]=lv;



        for(int i=0;i<sz(v[cur]);i++){

            int nw=v[cur][i];

            if(vis[nw]) continue;

            vis[nw]=1;

            par[nw]=cur;

            q.push(nw);

        }

    }

  }

}

bool go(int no){



   int cur=no,cnt=0;

   while(1){



    int pp=par[cur];

  //  cout<<pp<<endl;

    if(pp==-1) break;

    cnt++;

    if(ass[cur]==-1){



        ass[cur]=pp;

        cur=pp;

    }

    else if(ass[cur]==pp){



        if(dist[no]==cnt+dist[pp]){

            return 1;

        }

        else{

            return 0;

        }

    }

    else{

        return 0;

    }



   }

  return 1;

}

int main(){

    GO();

    int n,m;

    cin>>n>>m;

    for(int i=0;i<m;i++){

        int a,b;

        cin>>a>>b;

        v[a].pb(b);

        v[b].pb(a);

    }

    bfs(1);

    /*

    for(int i=1;i<=n;i++){

        cout<<dist[i]<<endl;

    }

    */

    clr(ass,-1);

    for(int i=2;i<=n;i++){



        int ret=go(i);

        if(ret==0){

            //cout<<i<<endl;

            cout<<"No\n";

            return 0;

        }

    }

    cout<<"Yes\n";

    for(int i=2;i<=n;i++){

      cout<<ass[i]<<"\n";

    }



}
















































// Faster C++ solution for the same problem (measured speedup: 1.1122926836154488x):
#include <bits/stdc++.h>

#include <ext/pb_ds/assoc_container.hpp> // Common file

#include <ext/pb_ds/tree_policy.hpp>

#define sz(v)   ((int)(v).size())

#define  all(v)    ((v).begin()),((v).end())

#define  allr(v)    ((v).rbegin()),((v).rend())

#define   pb         push_back

#define   mp         make_pair

#define    Lcm(a,b)  ((a*b)/(__gcd(a,b)))

#define    clr(v,d)      memset( v, d ,sizeof(v))

#define    PI            acos(-1)

typedef  long long     ll ;

typedef  unsigned long long     ull ;

const long double eps= (1e-9);

using namespace std;

using namespace __gnu_pbds;

int dcmp(long double a,long double b){   return fabsl(a-b)<=eps ? 0: (a>b)? 1:-1  ;}

void GO(){ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);}

const int N=100000+9;

vector< vector<int> > v(N);

int vis[N],par[N],dist[N],ass[N];

void bfs(int src){



  queue<int> q;

  q.push(src);

  vis[src]=1;

  dist[src]=0;

  par[src]=-1;

  int lv=-1;

  while(sz(q)>0){

    int siz=sz(q);

    lv++;

    while(siz--){



        int cur=q.front();

        q.pop();

        dist[cur]=lv;



        for(int i=0;i<sz(v[cur]);i++){

            int nw=v[cur][i];

            if(vis[nw]) continue;

            vis[nw]=1;

            par[nw]=cur;

            q.push(nw);

        }

    }

  }

}



int main(){

    GO();

    int n,m;

    cin>>n>>m;

    for(int i=0;i<m;i++){

        int a,b;

        cin>>a>>b;

        v[a].pb(b);

        v[b].pb(a);

    }

    bfs(1);



    cout<<"Yes\n";

    for(int i=2;i<=n;i++){

      cout<<par[i]<<"\n";

    }



}