#pragma GCC optimize("-Ofast","-funroll-all-loops")
#include<bits/stdc++.h>
//#define int long long
using namespace std;
const int N=1e5+10;
int n,m,d[N],pre[N];
vector<int> g[N];
inline void add(int a,int b){g[a].push_back(b),g[b].push_back(a);}
void bfs(){
	queue<int> q; memset(d,-1,sizeof d); q.push(1); d[1]=0;
	while(q.size()){
		int u=q.front();	q.pop();
		for(int to:g[u]) if(d[to]==-1) d[to]=d[u]+1,pre[to]=u,q.push(to);
	}
}
signed main(){
	cin>>n>>m;
	for(int i=1,a,b;i<=m;i++)	scanf("%d %d",&a,&b),add(a,b);
	bfs();
	for(int i=1;i<=n;i++)	if(d[i]==-1)	return puts("No"),0;
	puts("Yes");
	for(int i=2;i<=n;i++)	printf("%d\n",pre[i]);
	return 0;
}
