#include<stdio.h>
#include<stdlib.h>
int main(){
	int N, M;
	scanf("%d %d", &N, &M);
	int *node[N+1], n_edge[N+1];
	for(int i = 0; i <= N; i++){
		node[i] = NULL;
		n_edge[i] = 0;
	}
	for(int m = 1; m <= M; m++){
		int i, j;
		scanf("%d %d", &i, &j);
		n_edge[i]++;
		n_edge[j]++;
		node[i] = (int *) realloc(node[i], sizeof(int) * n_edge[i]);
		node[i][n_edge[i]-1] = j;
		node[j] = (int *) realloc(node[j], sizeof(int) * n_edge[j]);
		node[j][n_edge[j]-1] = i;
	}

	int start = 1, end = start, vacant = 2;
	int queue[N+1], state[N+1];
 	for(int i = 1; i <= N; i++)
    	state[i] = -1;
	queue[1] = 1;
	state[1] = 1;
	while(start <= end){
		for(int current = start; current <= end; current++){
			int base = queue[current]; 
			for(int i = 0; i < n_edge[base]; i++){
				int neighbor = node[base][i];
				if(state[neighbor] < 0){
					queue[vacant] = neighbor;
					state[neighbor] = base;
					vacant++;
				}
			}
		}
		start = end + 1; 
		end = vacant - 1;
	}
	printf("Yes\n");
	for(int n = 2; n <= N; n++)
		printf("%d\n", state[n]);
	for(int i = 0; i <= N; i++)
		free(node[i]);
	return 0;
}