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

#define min(a, b) ((a) < (b))?(a):(b)

#define INF 1001001001

struct list {
	int item;
	struct list * next;
} *to[100005];

void initializeList(int n)
{
	int i;
	for (i = 0; i < n; i++) {
		to[i] = NULL;
	}
}

struct list *insertList(int i, int x)
{
	struct list *p;
	if (to[i] == NULL) {
		to[i] = (struct list *)malloc(sizeof(struct list));
		to[i]->item = x;
		to[i]->next = NULL;
	} else {
		p = to[i];
		to[i] = (struct list *)malloc(sizeof(struct list));
		to[i]->item = x;
		to[i]->next = p;
	}

	return to[i];
}

struct queue {
	int item;
	struct queue *next;
} *head, *tail;

void initialize_queue(void)
{
	head = tail = (struct queue *)malloc(sizeof(struct queue));
}

void addqueue(int x)
{
	tail->item = x;
	tail->next = (struct queue *)malloc(sizeof(struct queue));
	tail = tail->next;
}

int removequeue(void)
{
	int x;
	struct queue *p;
	p = head;
	head = p->next;
	x = p->item;
	free(p);
	return x;
}

int main()
{
	int ret, i, n, m;
	int a, b;
	int *prev;
	int *dist;
	int v, u;
	struct list *pu;
	
	int ans;
	ret = scanf("%d %d", &n, &m);

	initializeList(n);
	prev = (int *) malloc(sizeof(int)*n);
	for (i = 0; i < n; i++)
		prev[i] = -1;
	dist = (int *) malloc(sizeof(int)*n);
	for (i = 0; i < n; i++)
		dist[i] = INF;
	
	for (i = 0; i < m; i++) {
		ret = scanf(" %d %d", &a, &b);
		--a;
		--b;
		to[a] = insertList(a, b);
		to[b] = insertList(b, a);
	}

	initialize_queue();
	dist[0] = 0;
	addqueue(0);
	do {
		v = removequeue();
		for (pu = to[v]; pu != NULL; pu = pu->next) {
			u = pu->item;
			if (dist[u] !=INF) continue;
			dist[u] = dist[v]+1;
			prev[u] = v;
			addqueue(u);
		}
	} while(head != tail);
	
	printf("Yes\n");
	for (i = 0; i < n; i++) {
		if (i == 0) continue;
		ans = prev[i];
		++ans;
		printf("%d\n", ans);
	}
	
	fflush(stdout);
	free(prev);
	free(dist);
	return EXIT_SUCCESS;
}
