#include<bits/stdc++.h>
#define r(i,n) for(int i=0;i<(n);i++)
using namespace std;int n,m,v,u,p[1<<17];vector<int>G[1<<17];queue<int>q;int main(){cin>>n>>m;r(i,m){cin>>u>>v,G[u].push_back(v),G[v].push_back(u);}q.push(1);p[1]=1;while(!q.empty()){u=q.front();q.pop();for(int e:G[u])if(!p[e])q.push(e),p[e]=u;}	puts("Yes");r(i,n-1)cout<<p[i+2]<<endl;}