#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main()
{
	ios::sync_with_stdio(false);
	cin.tie(NULL);
	int n,m,u,v;
	cin>>n>>m;
	vector<vector<int>> adj(n+1,vector<int>());
	for(int i=0; i<m; i++)
	{
		cin>>u>>v;
		adj[u].push_back(v);
		adj[v].push_back(u);
	}
	vector<int> par(n+1,-1);
	par[0] = 0;
	par[1] = 0;
	queue<int> q;
	q.push(1);
	while(!q.empty())
	{
		u = q.front();
		q.pop();
		for(auto& v: adj[u])
		{
			if(par[v]==-1)
			{
				par[v] = u;
				q.push(v);
			}
		}
	}
	if(*min_element(par.begin(), par.end())==-1)
		cout<<"No\n";
	else{
		cout<<"Yes\n";
		for(int i=2; i<=n; i++)
			cout<<par[i]<<"\n";
	}
}