#include<bits/stdc++.h>
using namespace std;
#pragma GCC optimize("O2")
typedef long long ll;

const int N = 100005;
const int inf = 0x7ffffff;
ll n, d[N], sign[N];
bool vis[N];
vector<int> e[N << 1];

void spfa()
{
	queue<int> q;
	for (int i = 1; i <= n; i++) d[i] = inf;
	q.push(1);
	vis[1] = 1;
	d[1] = 0;
	while (!q.empty())
	{
		int t = q.front();
		q.pop();
		vis[t] = 0;
		for (auto i:e[t])
		{
			if (d[i] > d[t] + 1)
			{
				d[i] = d[u] + 1;
				sign[i] = t;
				if (!vis[i]) q.push(i), vis[i] = 1;
			}
		}
	}
	bool check = 1;
	for (int i = 2; i <= n; i++)
		if (d[i] == inf)
		{
			check = 0;
			break;
		}
	if (!check) cout << "No\n";
	else
	{
		cout << "Yes\n";
		for (int i = 2; i <= n; i++)
			cout << sign[i] << endl;
	}
}

int main()
{
	ios::sync_with_stdio(false);
    cin >> n >> m;
    for (int i = 1, u, v; i <= m; i++)
    {
    	cin >> u >> v;
    	e[u].push_back(v);
    	e[v].push_back(u);
	}
	spfa();
	return 0;
}