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

typedef long long ll;
typedef long double ld;

#define imx INT_MAX
#define imn INT_MIN
#define llmx LLONG_MAX
#define llmn LLONG_MIN
#define INF         100000000000000000
#define PI          3.1415926535897932384626433832795l



#define fi first
#define se second
#define pb push_back
#define f_s(a) sort(a.begin(), a.end())
#define b_s(a) sort(a.rbegin(), a.rend())
#define p(a) cout<<a<<"\n"


// ll mod = 1000000007;
// #define l(i, )
// #define rl(i, a, b) for(int i = a; i < b; i++)






// struct mycomp {
//     bool operator() (const pair<int,int> &a, const pair<int,int> &b) const{
//         if (a.second-a.first != b.second-b.first)
//         return (a.second-a.first > b.second-b.first);
//         return a.first < b.first;
//     }
// };



/////////////////////GCD//////////////////////
ll gcd(ll a, ll b)
{
	if(b==0) return a;
	return gcd(b, a%b);
}


ll extended_gcd(ll a, ll b, ll& x, ll& y)
{
	if(b==0)
	{
		x=1;
		y=0;
		return a;
	}
	ll x1, y1;
	ll d = extended_gcd(b, a%b, x1, y1);
	x=y1;
	y=x1-y1*(a/b);
	return d;
}

////////////////////SIEVE OF ERATOSTHENES//////////////////////
vector<int> sieveoferatosthenes(int n)
{
	vector<bool> prime(n+1, true);
	for(int i = 2; i <= sqrt(n); i++)
	{
		if(prime[i])
		{
			for(int j = i*i; j<=n; j+=i)
			{
				prime[j]=false;
			}
		}
	}
	vector<int> all_primes;
	for(int i = 2; i <=n; i++)
	{
		if(prime[i]) all_primes.pb(i);
	}
	return all_primes;
}

////////////////////BINARY EXPONENTIATION///////////////////////
ll bin_exp(ll a, ll b, ll mod)
{
	ll ans = 1;
	while(b)
	{
		if(b%2)
		{
			b--;
			ans = (ans%mod*a%mod)%mod;
		}
		b/=2;
		a = (a%mod*a%mod)%mod;
	}
	return ans;
}
void bfs(vector<int>& distance, vector<int> a[], vector<bool>& visited, int u, vector<int>& parent)
{
	visited[u]=true;
	parent[u]=-1;
	distance[u]=0;
	queue<int> q;

	q.push(u); 
    // v[u] = true; 
  
    while (!q.empty()) { 
  
        int f = q.front(); 
        q.pop(); 
  
        // cout << f << " "; 
  
        // Enqueue all adjacent of f and mark them visited  
  		for(int i =0; i < a[f].size(); i++)
  		{
  			if(visited[a[f][i]]==false)
  			{
  				distance[a[f][i]]=distance[f]+1;
  				parent[a[f][i]]=f;
  				visited[a[f][i]]=true;
  				q.push(a[f][i]);
  			}
  		}
        // for (auto i = g[f].begin(); i != g[f].end(); i++) { 
        //     if (!v[*i]) { 
        //         q.push(*i); 
        //         v[*i] = true; 
        //     } 
        // } 
    } 

}
int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);

	// #ifndef ONLINE_JUDGE
	// freopen("input.txt", "r", stdin);
	// freopen("output.txt", "w", stdout);
	// #endif

	int n, m, x, y;
	cin>>n>>m;
	vector<int> a[n+1];
	for(int i = 0; i < m; i++)
	{
		cin>>x>>y;
		a[x].pb(y);
		a[y].pb(x);
	}
	vector<int> distance(n+1, 0), parent(n+1, 0);
	vector<bool> visited(n+1, false);
	bfs(distance, a, visited, 1,  parent);
	// {

	// }

	// for(auto i:visited)
	// {
	// 	if(i==false)
	// }

	// for(int i = 1; i <= n; i++)
	// {
	// 	cout<<visited[i]<<" ";
	// }
	// cout<<endl;
	int ans = 0;
	for(int i =1; i <=n; i++)
	{
		if(visited[i]==false)
		{
			ans = -1;
			break;
		}
	}
	if(ans==-1)
	{
		p("No");
	}
	else
	{
		p("Yes");
		for(int i = 2; i <=n; i++)
		{
			p(parent[i]);
		}
	}
	
	return 0;
}

Measured memory_bytes: 10652