#include <bits/stdc++.h>
#define N 100005
using namespace std;
int n, m, i, j, k, a, b, h[N], f[N], q[N];
struct AB{
	int a, b;
} d[N*4];
int cmp(AB a, AB b){
	return a.a < b.a;
}
int main(){
	scanf("%d%d", &n, &m);
	for(i=1; i<=m; i++){
		scanf("%d%d", &a, &b);
		d[i+m].b = d[i].a = a;
		d[i+m].a = d[i].b = b;
	}
	sort(d+1, d+m*2+1, cmp);
	for(i=m*2; i>=1; i--) h[d[i].a] = i;
	f[1] = q[1] = 1;
	for(i=j=1; i<=j; i++){
		a = q[i];
		for(k=h[a]; d[k].a==a; k++){
			b = d[k].b;
			if(!f[b]){
				f[b] = a;
				q[++j] = b;
			}
		}
	}
	if(j != n) printf("No\n");
	else{
		printf("Yes\n");
		for(i=2; i<=n; i++) printf("%d\n", f[i]);
	}
	return 0;
}