#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <ctime>
#include <cassert>
#include <string>
#include <algorithm>
#include <vector>
#include <queue>
#include <stack>
#include <functional>
#include <iostream>
#include <map>
#include <unordered_map>
#include <set>
#include <unordered_set>
#include <cassert>
#include <climits>
#include <iomanip>

using namespace std;

typedef long long ll;
typedef pair<int,int> P;
typedef pair<P,int> P1;
typedef pair<P,P> P2;

#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl "\n"

#define INF 1000000000
#define mod 1000000007
#define MAX5 100001

#define rep(i,x) for(int i=0;i<x;i++)
#define repn(i,x) for(int i=1;i<=x;i++)
#define SORT(x) sort(x.begin(),x.end())
#define ERASE(x) x.erase(unique(x.begin(),x.end()),x.end())
#define POSL(x,v) (lower_bound(x.begin(),x.end(),v)-x.begin())
#define POSU(x,v) (upper_bound(x.begin(),x.end(),v)-x.begin())

// cout << setfill('0') << setw(5) << number < endl;
// while(getline(cin, s)) { .. } | `s` is a string


const int N = 10000000;
// int lp[N+1];
// vector<int> pr;

// void si() {
// 	for (int i=2; i<=N; ++i) {
// 	    if (lp[i] == 0) {
// 	        lp[i] = i;
// 	        pr.push_back (i);
// 	    }
// 	    for (int j=0; j<(int)pr.size() && pr[j]<=lp[i] && i*pr[j]<=N; ++j)
// 	        lp[i * pr[j]] = pr[j];
// 	}
// }

// bool notPrime(int n) {
// 	auto iter = lower_bound(pr.begin(), pr.end(), n);
// 	return !(iter != pr.end() && *iter == n);
// }

// vector<int> pr;

// void sivOld() {
// 	std::vector<bool> primes(N, true);
// 	vector<char> is_prime(N+1, true);
// 	is_prime[0] = is_prime[1] = false;
// 	for (int i = 2; i <= N; i++) {
// 	    if (is_prime[i] && (long long)i * i <= N) {
// 	    	pr.push_back(i);
// 	        for (int j = i * i; j <= N; j += i)
// 	            is_prime[j] = false;
// 	    }
// 	}
// }

// int gcd(int a, int b) {
// 	while (b != 0) {
// 		int old_a = a;
// 		int old_b = b;

// 		a = old_b;
// 		b = old_a % old_b;
// 	}

// 	return a;
// }

// int returnPrime(int num, int a) {
// 	// cout << "?" << endl;
// 	for (int i = 0; i < pr.size(); ++i) {
// 		if (gcd(num, pr[i]) == 1 && gcd(a, pr[i]) == 1)
// 			return pr[i];
// 	}
// 	return -1;
// }


void solve() {
	int n, m, a, b;
	cin >> n >> m;
	vector<vector<int>> adj(n+1);
	vector<int> res(n+1, -1);
	vector<bool> visited(n+1, false);

	for (int i = 0; i < m; ++i) {
		cin >> a >> b;
		adj[a].push_back(b);
		adj[b].push_back(a);
	}

	queue<int> q;
	q.push(1);
	res[1] = 0;
	visited[1] = true;
	int cost = 1;
	while (!q.empty()) {
		int x =q.size();
		// cout << "Cost : " << cost-1 << endl;
		for (int i = 0; i < x; ++i) {
			int node = q.front();
			q.pop();
			// cout << "\tnode : " << node << endl;
			for (auto &it : adj[node]) {
				if (not visited[it]) {
					// cout << "-> " << it << endl;
					visited[it] = true;
					res[it] = node;
					q.push(it);
				}
			}
		}
		
		cost++;
	}

	for (int i = 2; i <= n; ++i) {
		if (res[i] == -1) {
			cout << "No" << endl;
			return ;
		}
	}

	cout << "Yes" << endl;
	for (int i = 2; i <= n; ++i) {
		cout << res[i] << endl;
	}

}

int main(){
	IOS;
	#ifndef ONLINE_JUDGE
	    // for getting input from input.txt
	    freopen("input.txt", "r", stdin);
	    // for writing output to output.txt
	    freopen("output.txt", "w", stdout);
	#endif
	    // return 0;
	    // cout << "gcd(10, 15) : " << gcd(1, 1) << endl;
	
	
	solve();
}

/*
11 
4 4 
-2 -2 
-3 -4 
-1 3 
2 3 
-4 0 
1 1 
-1 -1 
3 -1 
-4 2 
-2 4
*/

















Measured memory_bytes: 10300