#include <bits/stdc++.h>

// definitions
#define F first
#define S second
#define all(x) x.begin(), x.end()
#define clr(x) memset(x, 0, sizeof(x))
#define rep(i, l, r) for (long long i = (l); i < (long long)(r); i++)
#define repb(i, r, l) for (long long i = (r); i > (long long)(l); i--)
#define pb push_back
#define pf push_front
#define mod1 998244353
#define mod 1000000007
#define MAX_CHAR 256
#define INF 0x3f3f3f3f 



using namespace std;
typedef vector<long long> vl;
typedef vector<char> vc;
typedef vector<string> vs;
typedef vector< pair<long long, long long> > vp;
typedef vector<tuple<long long , long long , long long> > vtup;
typedef deque <long long> dql;
typedef deque <char> dqc;
typedef long double ld;
typedef long long ll;
typedef unsigned long long ull;


// prevent collisions in unordered_map
struct custom_hash {
    static uint64_t splitmix64(uint64_t x) {
        x += 0x9e3779b97f4a7c15;
        x = (x ^ (x >> 30)) * 0xbf58476d1ce4e5b9;
        x = (x ^ (x >> 27)) * 0x94d049bb133111eb;
        return x ^ (x >> 31);
    }

    size_t operator()(uint64_t x) const {
        static const uint64_t FIXED_RANDOM = chrono::steady_clock::now().time_since_epoch().count();
        return splitmix64(x + FIXED_RANDOM);
    }
};

typedef unordered_map <long long, long long, custom_hash> umap;


// standard functions
ll mystoi(string str)
{
    stringstream ss(str);
    ll ans=0;
    ss >> ans;

    return ans;
}


ll exp(ll x, ll ex) {
    ll ans = 1ll;
    while (ex > 0) {
        if (ex & 1ll) ans = (ans * x);
        ex >>= 1ll;
        x = (x * x);
    }
    return ans;
} 
 
ll nCrModp(ll n, ll r, ll p) 
{ 
    ll C[r+1]; 
    memset(C, 0, sizeof(C)); 
  
    C[0] = 1; 
    for (ll i = 1; i <= n; i++) 
    { 
        for (ll j = min(i, r); j > 0; j--) 
            C[j] = (C[j] + C[j-1])%p; 
    } 
    return C[r]; 
}
 
bool isPrime(ll n) 
{ 
    if (n <= 1)  return false; 
    if (n <= 3)  return true;  
    if (n%2 == 0 || n%3 == 0) return false; 
  
    for (ll i=5; i*i<=n; i=i+6) 
        if (n%i == 0 || n%(i+2) == 0) 
           return false; 
  
    return true; 
}

bool sort_cond(const pair<ll,ll> &a, const pair <ll,ll> &b)
{
    return a.second > b.second;
}

const ll MAXSIEVE=(1e3+5);
ll spf[MAXSIEVE];
void sieve() 
{ 
    spf[1] = 1; 
    for (ll i=2; i<MAXSIEVE; i++) 
        spf[i] = i; 

    for (ll i=4; i<MAXSIEVE; i+=2) 
        spf[i] = 2; 
  
    for (ll i=3; i*i<MAXSIEVE; i++) 
    { 
        if (spf[i] == i) 
        { 
            for (ll j=i*i; j<MAXSIEVE; j+=i) 
                if (spf[j]==j) 
                    spf[j] = i; 
        } 
    } 
}

ll V=1e5+5;
typedef pair<ll, ll> iPair; 
vector<ll> dist(V, INF); 
class Graph { 
    ll V; 
    list<pair<ll, ll> >* adj; 
  
public: 
    Graph(ll V); 
  
    
    void addEdgeRev(ll u, ll v, ll w); 
    void shortestPath(ll s); 
}; 
 
Graph::Graph(ll V) 
{ 
    this->V = V; 
    adj = new list<iPair>[V]; 
} 
  
void Graph::addEdgeRev(ll u, ll v, ll w) 
{ 
  
    adj[v].push_back(make_pair(u, w)); 
} 
  
void Graph::shortestPath(ll dest) 
{ 
     
    priority_queue<iPair, vector<iPair>, greater<iPair> > pq; 
  

    pq.push(make_pair(0, dest)); 
    dist[dest] = 0; 

    while (!pq.empty()) { 
        ll u = pq.top().second; 
        pq.pop(); 
  
        list<pair<ll, ll> >::iterator i; 
        for (i = adj[u].begin(); i != adj[u].end(); ++i) { 
 
            ll v = (*i).first; 
            ll weight = (*i).second; 
   
            if (dist[v] > dist[u] + weight) { 
                dist[v] = dist[u] + weight; 
                pq.push(make_pair(dist[v], v)); 
            } 
        } 
    } 
  
    // printf("Destination Vertex Distance "
    //        "from all vertex\n"); 
    // for (ll i = 0; i < V; ++i) 
    //     printf("%d \t\t %d\n", i, dist[i]); 

    // return dist;
} 


// code beigns in main
int main()
{

    #ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
    #endif
    
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    ll t=1;
    // cin >> t;
    ll lol;
    //
    while(t--)
    {
        ll n,m;
        cin >> n >> m;

        Graph g(n);
        vp v;
        rep(i,0,m)
        {
            ll a,b;
            cin >> a>>b;

            g.addEdgeRev(a-1,b-1,1);
            g.addEdgeRev(b-1,a-1,1);
            v.pb({a-1,b-1});
        }

        g.shortestPath(0);

        // rep(i,0,n)
        // cout << dist[i] << endl;

        ll ans[n];
        memset(ans,-1,sizeof(ans));

        rep(i,0,m)
        {
            ll x=v[i].F;
            ll y=v[i].S;

            if((dist[y]+1)<=dist[x])
            {
                ans[x]=y;
                dist[x]=dist[y]+1;
            }
            if((dist[x]+1)<=dist[y])
            {
                ans[y]=x;
                dist[y]=dist[x]+1;
            }
        }
        bool ok=1;
        rep(i,1,n)
        {
            if(ans[i]==-1)
            {
                ok=0;
                break;
            }
        }

        if(ok)
        {
            cout << "Yes" << endl;
            rep(i,1,n)
            cout << ans[i]+1 << endl;
        }

        else
            cout << "No" << endl;

    }
}


Measured memory_bytes: 31816