#include <stdio.h>
#include <stdlib.h>
int *G[100000];
int n, m;
int dist[100000];
int q[100000], head, tail;
void bfs(int st) {
	for (int i = 0; i < n; i++) {
		dist[i] = -1;
	}
	dist[st] = 0;
	head = tail = 0;
	q[tail] = st;
	tail++;
	while (head != tail) {
		// q[head] -> no ?
		for (int i = 0; G[q[head]][i] != -1; i++) {
			int no = G[q[head]][i];
			if (0 <= no && no < n && dist[no] == -1) {
				dist[no] = dist[q[head]] + 1;
				q[tail] = no;
				tail++;
			}
		}
		head++;
	}
}
int main() {
	int cnts[100000] = {0}, pos[100000] = {0};
	int a[100000] = {0}, b[100000] = {0};
	scanf("%d%d", &n, &m);
	for (int i = 0; i < m; i++) {
		scanf("%d%d", &a[i], &b[i]);
		a[i]--;
		b[i]--;
		cnts[a[i]]++;
		cnts[b[i]]++;
	}
	for (int i = 0; i < n; i++) {
		G[i] = malloc(sizeof(int) * cnts[i + 1]);
		if (G[i] == NULL) {
			return -1;
		}
	}
	for (int i = 0; i < m; i++) {
		G[a[i]][pos[a[i]]] = b[i];
		pos[a[i]]++;
		G[b[i]][pos[b[i]]] = a[i];
		pos[b[i]]++;
	}
	for (int i = 0; i < n; i++) {
		G[i][pos[i]] = -1;
	}
	bfs(0);
	printf("Yes\n");
	for (int i = 1; i < n; i++) {
		for (int j = 0; G[i][j] != -1; j++) {
			if (dist[G[i][j]] - dist[i] == -1) {
				printf("%d\n", G[i][j] + 1);
				break;
			}
		}
	}
	for (int i = 0; i < n; i++) {
		free(G[i]);
	}
	return 0;
}
