#include<bits/stdc++.h>
    #include <ext/pb_ds/assoc_container.hpp> 
    #include <ext/pb_ds/tree_policy.hpp> 
    #define ll long long
    #define MP make_pair
    #define PB push_back
    #define F first
    #define S second
    #define endl "\n"
    #define MOD 30000000000000000
    #define INF -100000000000000
    #define ordered_set tree<ll int, null_type,less<ll int >, rb_tree_tag,tree_order_statistics_node_update> 
    #define fast ios_base::sync_with_stdio(0);cin.tie(NULL);cout.tie(NULL);
    using namespace std;
    #define hell 1111111111111111111
    #define MAXN 10000005
    #define lld long double
    using namespace __gnu_pbds; 
    ll int power(ll int x,ll int y) 
    { 
        ll int res = 1;     // Initialize result 
       
        while (y > 0) 
        { 
            // If y is odd, multiply x with result 
            if (y & 1) 
                res = res*x; 
       
            // y must be even now 
            y = y>>1; // y = y/2 
            x = x*x;  // Change x to x^2 
        } 
        return res; 
    }
    int spf[MAXN]; 

    //set<ll int> s;
    vector<ll int> ans;
    /*bool prime[10000005];
    void SieveOfEratosthenes(ll int n) 
    { 
        // Create a boolean array "prime[0..n]" and initialize 
        // all entries it as true. A value in prime[i] will 
        // finally be false if i is Not a prime, else true. 
       

        //memset(prime, true, sizeof(prime)); 
      
        for (ll int p=2; p*p<=n; p++) 
        { 
            // If prime[p] is not changed, then it is a prime 
            if (prime[p] == true) 
            { 
                // Update all multiples of p greater than or  
                // equal to the square of it 
                // numbers which are multiple of p and are 
                // less than p^2 are already been marked.  
                for (int i=p*p; i<=n; i += p) 
                    prime[i] = false; 
            } 
        } 
        for(ll int i=2;i<=n;i++)
        {
            if(prime[i]==true)
            {
                mp[i]
            }
        }*/
        // Print all prime numbers 
        

    void sieve() 
    { 
        spf[1] = 1; 
        for (int i=2; i<MAXN; i++) 
      
            // marking smallest prime factor for every 
            // number to be itself. 
            spf[i] = i; 
      
        // separately marking spf for every even 
        // number as 2 
        for (int i=4; i<MAXN; i+=2) 
            spf[i] = 2; 
      
        for (int i=3; i*i<MAXN; i++) 
        { 
            // checking if i is prime 
            if (spf[i] == i) 
            { 
                // marking SPF for all numbers divisible by i 
                for (int j=i*i; j<MAXN; j+=i) 
      
                    // marking spf[j] if it is not  
                    // previously marked 
                    if (spf[j]==j) 
                        spf[j] = i; 
            } 
        } 
    } 
      map< int,int> countt,c1;
    // A O(log n) function returning primefactorization 
    // by dividing by smallest prime factor at every step 
    void getFactorization(int x) 
    { 
        //vector<int> ret;
        map<ll int,ll int> mp; 
        while (x != 1) 
        { 
          //  ret.push_back(spf[x]);
            if(mp[spf[x]]==0)
            {countt[spf[x]]++;

            c1[spf[x]]++;
            mp[spf[x]]++;
            }
            x = x / spf[x]; 
        } 
        //return ret; 
    } 
    int main()
    {
        fast;
       // #ifndef ONLINE_JUDGE
       // freopen("input.txt", "r", stdin);
       // freopen("output.txt", "w", stdout);
       // #endif
        ll int n,m;
        cin>>n>>m;
        ll int x,y,i;
        vector<ll int> v[n+1];
        for(i=1;i<=m;i++)
        {
            cin>>x>>y;
            v[x].PB(y);
            v[y].PB(x);
        }
        if(v[1].size()==0)
        {
            cout<<"No\n";
            exit(0);
        }
        deque<pair<ll int,ll int>> q;
        ll int f[n+1]={0};
        for(i=0;i<v[1].size();i++)
        {
            q.PB({v[1][i],1});
            f[v[1][i]]=1;
        }
        ll int topoint;
        while(q.empty()!=true)
        {
            pair<ll int,ll int> z=q.front();
            q.pop_front();
            topoint=z.F;
            for(i=0;i<v[z.F].size();i++)
            {
                if(f[v[z.F][i]]==0)
                {
                    q.PB(MP(v[z.F][i],z.F));
                    f[v[z.F][i]]=z.F;
                }
            }
        }
        ll int now=2,c=0;
        ll int flag=0;
        while(1)
        {c++;
            if(now==1)
            {
                cout<<"Yes\n";
                flag=1;
                break;
            }
            now=f[now];
            if(c>m)
            {
                cout<<"No\n";
                exit(0);
            }

        }
        for(i=2;i<=n;i++)
        {
            if(f[i]==0)
            {
                cout<<v[i][0]<<endl;
            }
            else
                cout<<f[i]<<endl;
        }
    }




Measured memory_bytes: 13704