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

int N, M;
int ec[114514];
int* es[114514];

void ae(int f, int t) {
	es[f] = realloc(es[f], sizeof(int) * (ec[f] + 1));
	if (es[f] == NULL) exit(2);
	es[f][ec[f]++] = t;
}

int ayaneru[114514];

int qs, qe;
int q[114514];

int main(void) {
	int i;
	if (scanf("%d%d", &N, &M) != 2) return 1;
	for (i = 0; i < M; i++) {
		int A, B;
		if (scanf("%d%d", &A, &B) != 2) return 1;
		ae(A, B);
		ae(B, A);
	}
	q[0] = 1;
	ayaneru[1] = -1;
	qs = 0;
	qe = 1;
	while (qs < qe) {
		int node = q[qs];
		qs++;
		for (i = 0; i < ec[node]; i++) {
			int next = es[node][i];
			if (ayaneru[next] == 0) {
				ayaneru[next] = node;
				q[qe++] = next;
			}
		}
	}
	for (i = 1; i <= N; i++) {
		if (ayaneru[i] == 0) {
			puts("No");
			return 0;
		}
	}
	puts("Yes");
	for (i = 2; i <= N; i++) {
		printf("%d\n", ayaneru[i]);
	}
	return 0;
}

