#include<bits/stdc++.h>
using namespace std;
vector<int> E[100010];
int p[100010];
int main() {
	ios_base::sync_with_stdio(0); cin.tie(0);
	int n, m;
	cin >> n >> m;
	for (int i = 1; i <= m; ++i) {
		int u, v;
		cin >> u >> v;
		E[u].push_back(v);
		E[v].push_back(u);
	}
	queue<int> q;
	q.push(1);
	while(q.empty() == false) {
		int u = q.front();
		q.pop();
		for (int v : E[u]) {
			if (p[v] == 0) {
				p[v] = u;
				q.push(v);
			}
		}
	}
	for (int i = 2; i <= n; ++i) {
		if (p[i] == 0) {
			cout << "No\n";
			return 0;
		}
	}
	cout << "Yes\n";
	for (int i = 2; i <= n; ++i) {
		cout << p[i] << '\n';
	}
}	