#include <stdio.h>
#include <vector>
using namespace std;
vector<vector<int>> G;
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 min(int x, int y) {
	return x < y ? x : y;
}
int main() {
	scanf("%d%d", &n, &m);
	G.resize(n);
	for (int i = 0; i < m; i++) {
		int a, b;
		scanf("%d%d", &a, &b);
		a--;
		b--;
		G[a].push_back(b);
		G[b].push_back(a);
	}
	for (int i = 0; i < n; i++) {
		G[i].push_back(-1);
	}
	bfs(0);
	bool canReach = true;
	for (int i = 0; i < n; i++) {
		if (dist[i] == -1) {
			canReach = false;
			break;
		}
	}
	if (canReach) {
		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;
				}
			}
		}
	} else {
		printf("No\n");
	}
	return 0;
}
