#include<bits/stdc++.h>
//One implementation to rule them all?
#define db 				double
#define ll 				long long int
//#define ld				long long double
//#define int 			long long int
#define ull 			unsigned long long
#define fi 				first
#define se 				second
#define rep(i,a,n)      for(int i=a;i<n;i++)
#define repr(i,n,b)     for(int i=n;i>=b;i--)
#define endl 			'\n'
#define mem(a,b) 		memset(a, b, sizeof a)
#define mkp 			make_pair
#define pb 				push_back
#define max3(a,b,c) 	max(a,max(b,c))
#define min3(a,b,c) 	min(a,min(b,c))
#define w(t)            int t; cin>>t; while(t--)
#define all(a)			a.begin(), a.end()
#define sz(a)           int((a).size())
#define tr(container, it) \
for(auto it = container.begin(); it != container.end(); it++)
using namespace std;
typedef vector < int > vii;
typedef vector < ll > vll;
typedef vector < vii > vvi;
typedef pair < int,int > pii;
const db PI = 2*acos(0.0);
const int INF = 0x3f3f3f3f;
const ll LINF = (ll)2e18;
db eps       =			0.000001;
ll mod       =			(1e9+7);   //998244353
void print(vector <int> &arr){
    for(int i=0;i<arr.size();i++)
        cout<<arr[i]<<" ";
    
    cout<<endl;
}
void printll(vector <ll> &arr){
    for(int i=0;i<arr.size();i++)
        cout<<arr[i]<<" ";
    
    cout<<endl;
}

ll ncr(ll n, ll r)
{
    r=min(r,n-r);
    ll A[r],i,j,B[r];
    iota(A,A+r,n-r+1);  
    iota(B,B+r,1);     

    ll g;
    for(i=0;i<r;i++)
    for(j=0;j<r;j++)
    {
        if(B[i]==1)
            break;
        g=__gcd(B[i], A[j] );
        A[j]/=g;
        B[i]/=g;
    }
    ll ans=1;
    for(i=0;i<r;i++)
        ans=(ans*A[i]%mod);
    return ans;
}
const int SIZE=200001;
bool judgePermutation(int a[], int n){
    static int used[SIZE+1];
    for(int i = 1; i <= n; i++) used[i] = 0;
    for(int i = 0; i < n; i++) used[a[i]] = 1;
    for(int i = 1; i <= n; i++) {
        if(!used[i]) return 0;
    }
    return 1;
}
//DSU Implementation
void init(int idx[], int sz[],int n){
	rep(i,0,n) idx[i]=-1, sz[i]=1;
}
int root(int index, int idx[]){
	while(index!=idx[index]){
		index=idx[index];
	}
	return index;
}
bool qfind(int p, int q, int idx[]){
	return root(p,idx)==root(q,idx);
}
void qunion(int p, int q, int idx[], ll sz[]){
	int rootp=root(p,idx), rootq=root(q,idx);
	if(rootp==rootq) return;
	idx[rootq]=rootp;
	sz[rootp]+=sz[rootq];
}

int main(){	
//CONDITION && cout << "YES" || cout << "NO"; cout << '\n';
//////////////////////////////////////////////////////////////////////
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  cerr.tie(NULL);
//For fast IO
///////////////////////////////////////////////////////////////////// 
//  std::cout.unsetf ( std::ios::floatfield );  // floatfield not set
//  std::cout.precision(10);
//	freopen("input.txt","r",stdin);
//	freopen("output.txt","w",stdout);
	int n,m;
	cin>>n>>m;
	vvi adj(n);
	rep(i,0,m){
		int x,y;
		cin>>x>>y;
		x--; y--;
		adj[x].pb(y);
		adj[y].pb(x);
	}
//	rep(i,0,n){
//		cout<<i<<"-> ";
//		rep(ii,0,sz(adj[i])) cout<<adj[i][ii]<<" ";
//		cout<<endl;
//	}
	
	queue<int> q;
	vector<bool> used(n);
	vii p(n,-1);
	
	q.push(0);
	used[0] = true;
	p[0] = -1;
	while (!q.empty()) {
	    int v = q.front();
	    q.pop();
	    for (int u : adj[v]) {
	        if (!used[u]) {
	            used[u] = true;
	            q.push(u);
	            p[u] = v+1;
	        }
	    }
	}
	int f=1;
	rep(i,1,n){
		if(p[i]==-1){
			 cout<<"No"<<endl;
			 f=0;
		}
	}
	if(f){
		cout<<"Yes"<<endl;
		rep(i,1,n) cout<<p[i]<<endl;
	}
	return 0;
    }

Measured memory_bytes: 10268