#include<bits/stdc++.h>
 
using namespace std;

void Solve(){
	int n, m;
	cin>>n>>m;
	vector<int> g[n + 1];
	while(m--){
		int u, v;
		cin>>u>>v;
		g[u].push_back(v);
		g[v].push_back(u);
	}
	vector<bool> vst(n + 1);
	queue<int> q;
	vector<int> res(n + 1);
	q.push(1);
	vst[1] = true;
	while(!q.empty()){
		int current = q.front();
		q.pop();
		for(auto x: g[current]){
			if(!vst[x]){
				vst[x] = true;
				q.push(x);
				res[x] = current;
			}
		}
	}
	cout<<"Yes\n";
	for(int i = 2; i <= n; i++) cout<<res[i]<<'\n';
}
int main(){
	ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
	int T = 1;
	//cin>>T;
	while(T--){
		Solve();
	}
}