#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const int inf = 1e9 + 7;
const ll longinf = 5LL << 60;
const ll mod = 1e9 + 7;

using Graph = vector<vector<int>>;

int main() {
	int N, M;
	cin >> N >> M;

	Graph G(N);
	for(int i = 0; i < M; ++i) {
		int a, b;
		cin >> a >> b;
		a--;
		b--;
		G[a].push_back(b);
		G[b].push_back(a);
	}

	vector<int> from(N, -1);
	queue<int> que;
	from[0] = 0;
	que.push(0);

	while(!que.empty()) {
		int v = que.front();
		que.pop();

		for(int nv : G[v]) {
			if(from[nv] != -1) continue;
			from[nv] = v;
			que.push(nv);
		}
	}
	cout << "Yes\n";
	for(int v = 1; v < N; ++v) cout << from[v] + 1 << "\n";
}