#include <bits/stdc++.h>

using namespace std;

bitset<1000010>verified;

int main(){

	int n,m,a,b,cont=1,aux;
	queue<int>q;
	cin >> n >> m;

	vector<vector<int>>v(n+10);
	vector<int>resp(n+10);
	
	q.push(1);
	verified[1]=true;

	while(m--){
		cin >> a >> b;
		v[a].push_back(b);
		v[b].push_back(a);
	}

	while(!q.empty()){
		aux = q.front();

		for(int i=0;i<v[aux].size();i++){
			if(verified[v[aux][i]]==true) continue;
			verified[v[aux][i]]=true;
			resp[v[aux][i]] = aux;
			cont++;
			q.push(v[aux][i]);
		}
		q.pop();
	}
	if(cont==n){
	cout << "Yes\n";

	for(int i=2;i<=n;i++) cout << resp[i] << endl;
	}

	else{
		cout << "No" << endl;
	}
	return 0;

}