#include<stdio.h>
#include<stdlib.h>
int main(){
	int N, M;
	scanf("%d %d", &N, &M);
	int *node[100001] = {0}, n_node[100001] = {0};
	for(int m = 1; m <= M; m++){
		int i, j;
		scanf("%d %d", &i, &j);
		n_node[i]++;
		n_node[j]++;
		node[i] = (int *) realloc(node[i], n_node[i]);
		node[i][n_node[i]-1] = j;
		node[j] = (int *) realloc(node[j], n_node[j]);
		node[j][n_node[j]-1] = i;
	}
  
	int start = 1, vacant = 2, end = start, queue[100001];
	int state[100001];
  for(int i = 1; i <= 100001; i++)
    state[i] = -1;
	queue[1] = 1;
	state[1] = 1;
	while(start <= end){
		for(int current = start; current <= end; current++){
			for(int i = 0; i < n_node[queue[current]]; i++){
				if(state[node[queue[current]][i]] < 0){
					queue[vacant] = node[queue[current]][i];
					state[node[queue[current]][i]] = queue[current];
					vacant++;
				}
			}
		}
		start = end + 1; 
		end = vacant - 1;
	}
	printf("Yes\n");
	for(int n = 2; n <= N; n++)
		printf("%d\n", state[n]);
	return 0;
}