#include <bits/stdc++.h>
using namespace std;
using pr = pair<int, int>;

int N, M, D[100005], pre[100005];
vector<int> v[100005];
queue<int> q;

int main() {
	scanf("%d %d", &N, &M);
	for(int i=0, x, y; i<M; i++) {
		scanf("%d %d", &x, &y);
		v[x].push_back(y), v[y].push_back(x);
	}
	q.push(1);
	for(int i=2; i<=N; i++) D[i] = 1e9;
	while(!q.empty()) {
		int u = q.front(); q.pop();
		for(auto it : v[u]) {
			if(D[it] > D[u] + 1) {
				D[it] = D[u] + 1;
				pre[it] = u;
				q.push(it);
			}
		}
	}
	for(int i=2; i<=N; i++) if(!pre[i]) return puts("No"),0;
	puts("Yes");
	for(int i=2; i<=N; i++) printf("%d\n", pre[i]);
}