#include <bits/stdc++.h>

using namespace std;
#define rep(i, n) for(int i=0;i<n;i++)
#define REP(i, n) for(int i=1;i<=n;i++)
typedef long long ll;

vector<int> to[200005];

int main() {
	int n, m;
	cin >> n >> m;
	vector<int> ans(n + 1, 0);
	rep(i, m) {
		int a, b;
		cin >> a >> b;
		to[a].push_back(b);
		to[b].push_back(a);
	}
	queue<int> que;
	que.push(1);
	while (!que.empty()) {
		int v = que.front();
		que.pop();
		for (auto next : to[v]) {
			if (ans[next] != 0) continue;
			ans[next] = v;
			que.push(next);
		}
	}
	cout << "Yes" << endl;
	for (int i = 2; i <= n; ++i) {
		cout << ans[i] << endl;
	}
	return 0;
}