// Problem : D - .. (Double Dots)
// Contest : AtCoder - AtCoder Beginner Contest 168
// URL : https://atcoder.jp/contests/abc168/tasks/abc168_d
// Memory Limit : 1024 MB
// Time Limit : 2000 ms
// Powered by CP Editor (https://github.com/cpeditor/cpeditor)

#include<bits/stdc++.h>
using namespace std; 
#define ll long long int
#define ld long double
#define pb push_back
#define mp make_pair
#define pll pair<ll,ll>
#define INF LLONG_MAX
#define PI acos(-1)
const ll MOD = 1e9 + 7;
#define fir first
#define sec second
#define all(x) x.begin(),x.end()
#define mem(a,b) memset(a,b,sizeof(a))
#define rep(c,a,b) for(ll c=a;c<b;c++)
#define IOS ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define min_heap priority_queue<pll,vector<pll>,greater<pll> >
template<int D, typename T>
struct Vec : public vector<Vec<D - 1, T>> {
  static_assert(D >= 1, "Vector dimension must be greater than zero!");
  template<typename... Args>
  Vec(int n = 0, Args... args) : vector<Vec<D - 1, T>>(n, Vec<D - 1, T>(args...)) {
  }
};
template<typename T>
struct Vec<1, T> : public vector<T> 
{
  Vec(int n = 0, const T& val = T()) : vector<T>(n, val) {}
};
ll dx4[]={-1,1,0,0};
ll dy4[]={0,0,-1,1};
ll dx8[]={-1,-1,-1,0,1,1,1,0};
ll dy8[]={-1,0,1,1,1,0,-1,-1};
bool isvalid(ll x,ll y,ll n,ll m)
{
    return (x>=0 and y>=0 and x<n and y<m);
}
vector<bool> isprime;
vector<ll> prime;
void sievetoprime(ll n)
{
    isprime.resize(n+1,true);
    for(ll p=2;p*p<=n;p++)
    {
        if(isprime[p]==true)
        {
            for(ll i=p*p;i<=n;i+=p)
                isprime[i]=false;
        }
    }
    for(ll i=1;i<=n;i++)
    {
    	if(isprime[i])
    		prime.pb(i);
    }
}
ll lcm(ll a,ll b)
{
    return (a/__gcd(a,b))*b;
}
//Disjoint-Set Union-find algorithm
void initialize_disjoint_set(vector<ll> &arr,vector<ll> &size,ll n)
{
	for(ll i=0;i<n;i++)
    {
		arr[i] = i ;
		size[i] = 1;
	}
}
ll root(vector<ll> &arr,ll i)
{
    while(arr[i] != i)
    {
		i=arr[i]; 
    }
	return i;
}

void unione(vector<ll> &arr,vector<ll> &size,ll a,ll b)
{
    ll root_A = root(arr,a);
    ll root_B = root(arr,b);
    if(size[root_A] < size[root_B ])
    {
		arr[root_A] = arr[root_B];
		size[root_B] += size[root_A];
	}
    else
    {
		arr[ root_B ] = arr[root_A];
		size[root_A] += size[root_B];
	}	
}
// Vec<1,ll> v(n,0);
vector<ll> adj[100000+1];
vector<ll> dis;
vector<ll> vis,ans;
void dijkstra()
{
	min_heap q;
	q.push({0,1});
	dis[1]=0;
	while(!q.empty())
	{
		ll u=q.top().sec;
		q.pop();
		
		for(auto i:adj[u])
		{
			if(dis[i]>dis[u]+1)
			{
				dis[i]=dis[u]+1;
				ans[i]=u;
				q.push({dis[i],i});
			}
		}
	}
}
void solve()
{
	ll n,m;
	cin>>n>>m;
	dis.resize(n+1,INF);
	vis.resize(n+1,0);
	ans.resize(n+1,0);
	ll a,b;
	rep(i,0,m)
	{
		cin>>a>>b;
		adj[a].pb(b);
		adj[b].pb(a);
	}
	dijkstra();
	for(ll i=2;i<=n;i++)
	{
		if(ans[i]==0)
		{
			cout<<"No\n";
			return;
		}
	}
	cout<<"Yes\n";
	rep(i,2,n+1)
		cout<<ans[i]<<"\n";
}
int main()
{
    ll inpoup = 0;
    if(inpoup==1)
    {
        #ifndef ONLINE_JUDGE
            freopen("input.txt","r",stdin);
            freopen("output.txt","w",stdout);
        #endif
    }
    IOS
    ll t;
    t=1;
    //cin>>t;
    while(t--)
    {
        solve();
    }
}


Measured memory_bytes: 15744