#include "bits/stdc++.h"
using namespace std;

int main()
{
	int n, m;
	cin >> n >> m;
	vector<vector<int>> ab(n);
	for (int i = 0; i < m; i++) {
		int a_in, b_in;
		cin >> a_in >> b_in;
		ab.at(a_in - 1).push_back(b_in - 1);
		ab.at(b_in - 1).push_back(a_in - 1);
	}

	vector<bool> seen(n, false);
	vector<int> parents(n);
	queue<int> q;

	q.push(0);
	while (!q.empty()) {
		int num = q.front();
		q.pop();
		for (auto ab_ele : ab.at(num)) {
			if (seen.at(ab_ele) == false) {
				seen.at(ab_ele) = true;
				q.push(ab_ele);
				parents.at(ab_ele) = num;
			}
		}
	}

	cout << "Yes" << endl;
	for (int i = 1; i < n; i++) {
		cout << parents.at(i) + 1 << endl;
	}
}
