#include<stdio.h>
#include<stdlib.h>

void Find_Shortest_Roots(int n_rooms, int **isConnected, int *state, int *queue){
	int look_at = 1, vacant_at = 2;
	while(vacant_at <= n_rooms){
		int count = 0;
		for(int room_i = 1; room_i <= n_rooms; room_i++){
			if(isConnected[queue[look_at]][room_i] && state[room_i] == -1){
				state[room_i] = queue[look_at];
				queue[vacant_at+count++] = room_i;
			}
		}
		vacant_at += count;
		look_at++;
	}
}

int main(){
	int n_rooms, n_edges;
	scanf("%d %d", &n_rooms, &n_edges);
	int **isConnected;
	isConnected = (int **) malloc(sizeof(int *) * (n_rooms+1));
	for(int room_i = 1; room_i <= n_rooms; room_i++){
		isConnected[room_i] = (int *) malloc(sizeof(int) * (n_rooms+1));
		for(int room_j = 1; room_j <= n_rooms; room_j++)
			isConnected[room_i][room_j] = 0;
	}
	for(int edge_i = 1; edge_i <= n_edges; edge_i++){
		int room_i, room_j;
		scanf("%d %d", &room_i, &room_j);
		isConnected[room_i][room_j] = isConnected[room_j][room_i] = 1;
	}

	int *state, *queue;
	state = (int *) malloc(sizeof(int) * (n_rooms+1));
	queue = (int *) malloc(sizeof(int) * (n_rooms+1));
	queue[1] = 1;
    state[1] = 1;
	for(int room_i = 2; room_i <= n_rooms; room_i++)
		state[room_i] = -1;
	Find_Shortest_Roots(n_rooms, isConnected, state, queue);

	printf("Yes\n");
	for(int room_i = 2; room_i <= n_rooms; room_i++)
		printf("%d\n", state[room_i]);

	for(int room_i = 0; room_i <= n_rooms; room_i++)
		free(isConnected[room_i]);
	free(isConnected);
	free(state);
	free(queue);
	return 0;
}