#include<bits/stdc++.h>
using namespace std;
namespace variables{
    typedef long double ld;
    typedef long long ll;
    typedef unsigned long long ull;
    typedef unsigned int uint;
    typedef pair<ll,ll> pll;
    template<typename T1, typename T2, typename T3>
    struct triple{
        T1 first;
        T2 second;
        T3 third;
    };
}
using namespace variables;
void debug(set<ll> _var,string _name=""){ cerr<<"Debug #set "<< _name<<" = ["; for(auto it : _var) cerr<<it<<","; cerr<<"en] : "<<"size = "<<_var.size()<<"\n\n";}
void light_debug(set<ll> _var,string _name=""){ cerr<<"Debug #set "<< _name<<" = ["; for(auto it : _var) cerr<<it<<","; cerr<<"en]\n\n";}
void debug(map<ll,ll> _var,string _name=""){ cerr<<"Debug #map (size = "<<_var.size()<<")\n"; for(auto it : _var) cerr<<_name<<"["<<it.first<<"] = "<<it.second<<'\n';}
void light_debug(map<ll,ll> _var,string _name=""){ cerr<<"Debug #map \n"; for(auto it : _var) cerr<<_name<<"["<<it.first<<"] = "<<it.second<<'\n';}
void debug(deque<ll> _var,string _name=""){ cerr<<"Debug #deque "<< _name<<" = ["; for(auto it : _var) cerr<<it<<","; cerr<<"en] : "<<"size = "<<_var.size()<<"\n\n";}
void light_debug(deque<ll> _var,string _name=""){ cerr<<"Debug #deque "<< _name<<" = ["; for(auto it : _var) cerr<<it<<","; cerr<<"en]\n\n";}
void debug(vector<ll> _var,string _name=""){ cerr<<"Debug #vector "<< _name<<" = ["; for(auto it : _var) cerr<<it<<","; cerr<<"en] : "<<"size = "<<_var.size()<<"\n\n";}
void light_debug(vector<ll> _var,string _name=""){ cerr<<"Debug #vector "<< _name<<" = ["; for(auto it : _var) cerr<<it<<","; cerr<<"en]\n\n";}
void debug(string _var,string _name=""){ cerr<<"Debug #string "<< _name<<" = "; cerr<<'"'<<_var<<'"'; cerr<<" : "<<"size = "<<_var.size()<<"\n\n";}
void light_debug(string _var,string _name=""){ cerr<<"Debug #string : "<<_name<<" = "<<'"'<<_var<<'"'<<"\n\n";}
void debug(ll _var,string _name=""){ cerr<<"Debug #int64 : "<<_name<<" = "<<_var<<"\n\n";}
void debug(ull _var,string _name=""){ cerr<<"Debug #uint64 : "<<_name<<" = "<<_var<<"\n\n";}
void debug(uint _var,string _name=""){ cerr<<"Debug #uint32 : "<<_name<<" = "<<_var<<"\n\n";}
void debug(int _var,string _name=""){ cerr<<"Debug #int32 : "<<_name<<" = "<<_var<<"\n\n";}
void debug(char _var,string _name=""){cerr<<"Debug #char : "<<_name<<" = '"<<_var<<"\n\n";}
void debug(bool _var,string _name=""){cerr<<"Debug #Boolean : "<<_name<<" = "<<(_var ? "1 True" : "0 False")<<"\n\n";}
void testt();
namespace data_structures{
    template<size_t maxalloc>
    class segment_tree{
        private : struct __st_node{int l,r,val;}_data[(size_t)(maxalloc*log(maxalloc)+5)];
        private : unsigned _leaves[maxalloc];
        private : bool isBuilt=0;
        private :  void construct(int _node = 0){
            _data[_node].val = 0;
            if(_node == 0){
                _data[_node].l = 0,_data[_node].r = maxalloc - 1;
                isBuilt = 1;
            }
            else{
                __st_node _parent = _data[(_node-1)/2];
                if(_node % 2)
                    _data[_node].l = _parent.l, _data[_node].r = (_parent.l + _parent.r)/2;
                else
                    _data[_node].l = (_parent.l + _parent.r)/2 + 1, _data[_node].r = _parent.r;\
            }
            if(_data[_node].l == _data[_node].r){
                _leaves[_data[_node].l] = _node;
            }
            else{
                construct(_node * 2 + 1);
                construct(_node * 2 + 2);
            }
        }
        public : void clear(int __cur_node = 0){
            if(isBuilt == 0)
                construct();
            _data[__cur_node].val = 0;
            if(_data[__cur_node].l != _data[__cur_node].r){
                clear(__cur_node * 2 + 1);
                clear(__cur_node * 2 + 2);
            }
        }
        public : void insert(int _val, int _amount = 1){
            if(isBuilt==0) construct();
            int _node = _leaves[_val];
            while(_node){
                _data[_node].val += _amount;
                _node = (_node -1)/2;
            }
            _data[0].val += _amount;
        }
        public : void erase(int _val, int _amount = 1){
            insert(_val, -_amount);
        }
        public : long long count(int _pos1, int _pos2){
            if(_pos1 > _pos2)
                return 0;
            int _node = _leaves[_pos1];
            while(_node > 0 && _data[(_node - 1)/2].l >= _pos1 && _data[(_node - 1)/2].r <= _pos2)
                _node = (_node - 1)/2;
            return (long long)_data[_node].val + count(_data[_node].r + 1, _pos2);
        }
    };
};
namespace cf_utilities{
    inline void multipleTests(){
        ll __test_count;
        cin>>__test_count;
        while(__test_count--) testt();
    }
    inline void fastIO(){ ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);}
}
namespace compare{
    template <char _cmp>
    bool compare(ll a,ll b){
        if(_cmp == '>') return a > b;
        else return a < b;
    }
    template <char _cmp1='<', char _cmp2='<'>
    bool compair(pll a, pll b){ /// HAHA pun
        return compare<_cmp1>(a.first, b.first) || (a.first == b.first && compare<_cmp2>(a.second, b.second));
    }
    struct objcompair{
        template <char _cmp1='<', char _cmp2='<'>
        bool operator () (pll a, pll b){
            return compare<_cmp1>(a.first, b.first) || (a.first == b.first && compare<_cmp2>(a.second, b.second));
        }
    };
}
namespace bin{
    ll trailingZeroes(ll x){
        if(x==0) return 0;
        return (x&1 ? 0 : 1 + trailingZeroes(x/2));
    }
    ll trailingOnes(ll x){
        if(x==0) return 0;
        return (x&1 ? 1 + trailingZeroes(x/2) : 0);
    }
    ll trailingPowerOfTwo(ll x){
        return 1ll<<trailingZeroes(x);
    }
    ll popCount(ll x){
        if(x == 0) return x;
        return 1 + popCount(x & (x - 1));
    }
}
namespace math{
    const ll MOD = 998244353, MODalt = 1000000007;
    ll binPow(ll _num, ll _exponent, ll _mod = MOD){ /// a^b
        if(_exponent == 0)
            return 1;
        ll _half = binPow(_num, _exponent/2, _mod);
        return _half * _half % _mod * (_exponent & 1 ? _num : 1) % _mod;
    }
    ll modularInverse(ll _x, ll _mod = MOD){ /// (a / b ) % mod
        return binPow(_x, _mod - 2, _mod);
    }
    ll comb(ll _n, ll _k, ll _mod = MOD){  /// binom(a, b)
        ll _ans=1;
        for(ll i = _n - _k + 1; i <= _n; i++)
            _ans = _ans * i % _mod;
        for(ll i = 2; i <= _k; i++)
            _ans = _ans * modularInverse(i, _mod) % _mod;
        return _ans;
    }
    void sieve(bool* _startpos, bool* _enpos){/// erathostenes' sieve; 0 means the number is prime; 1 means the number is composite
        ll _maxnum = _enpos - _startpos;
        for(ll i = 4; i < _maxnum; i += 2)
            *(_startpos + i) = 1;
        for(ll i = 3; i * i < _maxnum; i+= 2)
            if( *(_startpos + i) == 0)
                for(ll j = i * i; j < _maxnum; j+=i)
                    *(_startpos + j) = 1;
    }
}
namespace geometry{
    const ld PI = acos(-1), rad = 180 / PI;
    ld degsin(ll __alpha){ return sin(__alpha / rad);}
    ld degcos(ll __alpha){ return cos(__alpha / rad);}
    ld degtan(ll __alpha){ return tan(__alpha / rad);}
    ld arcsin(ll _sine){ return asin(_sine) * rad;}
    ld arccos(ll _cosine){ return acos(_cosine) * rad;}
    ld arctan(ll _tangent){ return atan(_tangent) * rad;}
}
using namespace cf_utilities; /// fastIO() and multipleTests()
using namespace compare; /// pair compare functions
using namespace bin; /// binary stuff
using namespace math; /// combinatorics and general maths stuff
using namespace geometry; /// fixed trigonometry functions, PI and radian
using namespace data_structures; /// segm_tree
/// - end of namespaces and start of program
#define NMAX 200009
void testt()
{
}
ll prv[NMAX],n,m;
bitset<NMAX> visited;
vector<int> adiac[NMAX];
void bfs(){
    visited[1]=1;
    queue<ll> q;
    q.push(1);
    while(!q.empty()){
        for(auto it : adiac[q.front()]){
            if(!visited[it]){
                q.push(it);
                visited[it]=1;
                prv[it]=q.front();
            }
        }
        q.pop();
    }
}
int main()
{
    fastIO();
    cin>>n>>m;
    ll a,b;
    for(ll i=0;i<m;i++){
        cin>>a>>b;
        adiac[a].push_back(b);
        adiac[b].push_back(a);
    }
    bfs();
    if(visited.count()==n){
        cout<<"Yes";
        for(ll i=2;i<=n;i++)
            cout<<'\n'<<prv[i];
    }
    else cout<<"No";
    return 0;
}


Measured memory_bytes: 13420