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

const int N = 4e5 + 5;
typedef long long ll;

struct Edge {
	int to, next;
} e[N];
int n, m, cnt, first[N], s[N], h, r, q[N<<2];

void add(int u, int v) {
	e[++cnt] = (Edge) {v, first[u]};
	first[u] = cnt;
}

int main() {
	cout<<"Yes"<<endl;
	cin>>n>>m;
	for(int i = 1; i <= m; i++) {
		int u, v;
		cin>>u>>v;
		add(u, v);
		add(v, u);
	}
	q[h = r = 1] = 1;
	while(h <= r) {
		int u = q[h];
		for(int i = first[u]; i; i = e[i].next) {
			int v = e[i].to;
			if(!s[v]) {
				s[v] = u;
				q[++r] = v;
			}
		}
		h++;
	}
	for(int i = 2; i <= n; i++)
		cout<<s[i]<<endl;
	return 0;
}