#include <bits/stdc++.h>
//                    #include <ext/pb_ds/assoc_container.hpp>
//                    #include <ext/pb_ds/tree_policy.hpp>

                    using ll = long long;
                    using ld = long double;
                    #define rep(i, a, n) for(ll i = (a); i < (n); i++)
                    #define per(i, a, n) for(ll i = (n-1); i >= (a); i--)
                    #define F first
                    #define S second
                    #define maxx(a, b) a = max(a, b)
                    #define minn(a, b) a = min(a, b)
                    #define db(x) cerr << #x << " = " << x << endl
                    #define N 1111111
                    #define mod 1000000007
                    #define rt return
                    #define inf 1234567891123456789ll

                    using namespace std;
                    random_device rd;
                    mt19937 mt(rd());
//                    using namespace __gnu_pbds;
//
//                    typedef tree<pair<ll,ll>, null_type, less<pair<ll,ll>>, rb_tree_tag, tree_order_statistics_node_update> indexed_set;

                    #define error(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args); }

                    void err(istream_iterator<string> it) {}
                    template<typename T, typename... Args>
                    void err(istream_iterator<string> it, T a, Args... args)
                    {
                        cerr << *it << " = " << a << endl;
                        err(++it, args...);
                    }

                    ll modlaber(ll a, ll m = mod)
                    {
                        rt ((a+m)%m+m)%m;
                    }

                    vector<int> g[N];
                    bitset<200002> used;

                    int main()
                    {
                        ios_base::sync_with_stdio(0);
                        cin.tie(0);
                        cout.tie(0);

                        int n,m; cin>>n>>m;
                        vector<int> ans(n+1);
                        rep(i,0,m)
                        {
                            int q,w; cin>>q>>w;
                            g[q].push_back(w);
                            g[w].push_back(q);
                        }

                        queue<int> q;
                        q.push(1);

                        while(!q.empty())
                        {
                            int now = q.front();
                            q.pop();
                            used[now] = 1;
                            for(auto x: g[now])
                            {
                                if(!used[x])
                                {
                                    if(ans[x] == 0)
                                        ans[x] = now;
//                                    else
//                                        minn(ans[x], ans[now]+1);
                                    q.push(x);
                                    used[x] = 1;
                                }
                            }
                        }

                        rep(i,2,n+1)
                            if(!ans[i])
                                rt cout<<"No",0;
                        cout<<"Yes\n";
                        rep(i,2,n+1)
                            cout<<ans[i]<<'\n';


                        rt 0;
                    }























Measured memory_bytes: 34008