#include <stdio.h>

typedef struct List {
	struct List *next;
	int v;
} list;

int main()
{
	int i, N, M, u, w;
	list *adj[100001] = {}, e[400001];
	scanf("%d %d", &N, &M);
	for (i = 0; i < M; i++) {
		scanf("%d %d", &u, &w);
		e[i*2].v = w;
		e[i*2+1].v = u;
		e[i*2].next = adj[u];
		e[i*2+1].next = adj[w];
		adj[u] = &(e[i*2]);
		adj[w] = &(e[i*2+1]);
	}
	
	int prev[200001] = {}, q[200001], head, tail;
	list *p;
	q[0] = 1;
	prev[1] = 1;
	for (head = 0, tail = 1; head < tail; head++) {
		u = q[head];
		for (p = adj[u]; p != NULL; p = p->next) {
			w = p->v;
			if (prev[w] == 0) {
				prev[w] = u;
				q[tail++] = w;
			}
		}
	}

	if (head == N) {
		printf("Yes\n");
		for (i = 2; i <= N; i++) printf("%d\n", prev[i]);
	} else printf("No\n");
	fflush(stdout);
	return 0;
}