#include <bits/stdc++.h>

using namespace std;

typedef long long int ll;
typedef unsigned long long int ull;
typedef vector<int> vii;
typedef vector<ll> vll;
typedef pair<int,int> pii;

#define FASTIO ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define pb push_back
#define odd(x) ((x)&1)
#define even(x) (!odd(x))
#define ff it->first
#define ss it->second
#define all(v) (v).begin(),(v).end()
#define rep(i,n) for(auto i=0;i<n;++i)
#define LOOP_IT(it,s) for(auto it=(s).begin();it!=(s).end();++it)


#ifdef LOCAL
#define cerr cout
#else
#endif

#define TRACE

#ifdef TRACE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
    cerr << name << " : " << arg1 << std::endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
    const char* comma = strchr(names + 1, ',');cerr.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
}
#else
#define trace(...)
#endif


void __print(int x) {cerr << x;}
void __print(long x) {cerr << x;}
void __print(long long x) {cerr << x;}
void __print(unsigned x) {cerr << x;}
void __print(unsigned long x) {cerr << x;}
void __print(unsigned long long x) {cerr << x;}
void __print(float x) {cerr << x;}
void __print(double x) {cerr << x;}
void __print(long double x) {cerr << x;}
void __print(char x) {cerr << '\'' << x << '\'';}
void __print(const char *x) {cerr << '\"' << x << '\"';}
void __print(const string &x) {cerr << '\"' << x << '\"';}
void __print(bool x) {cerr << (x ? "true" : "false");}


template<typename T, typename V>
void __print(const pair<T, V> &x) {cerr << '{'; __print(x.first); cerr << ','; __print(x.second); cerr << '}';}
template<typename T>
void __print(const T &x) {int f = 0; cerr << '{'; for (auto &i: x) cerr << (f++ ? "," : ""), __print(i); cerr << "}";}
void _print() {cerr << "]\n";}
template <typename T, typename... V>
void _print(T t, V... v) {__print(t); if (sizeof...(v)) cerr << ", "; _print(v...);}
#ifndef ONLINE_JUDGE
#define debug(x...) cerr << "[" << #x << "] = ["; _print(x)
#else
#define debug(x...)
#endif


const int N = 1e5+2,inf = 2e9;
vector<pair<int,int>> adj[N];
vii parent(N);
int n;

void add_edge_dj(int u,int v,int w)
{
    adj[u].pb({v,w});
    adj[v].pb({u,w});
}

bool dijkstra(int x)
{
    vii dis(N,inf);
    dis[x]=0;

    vector<bool> vis(N,0);

    priority_queue<pii,vector<pii>,greater<pii>> q;
    q.push({0,x});

    while(!q.empty())
    {
        int a = q.top().second;
        q.pop();
        if(vis[a]) continue;
        vis[a]=1;
        for(auto e : adj[a])
        {
            int b=e.first,w=e.second;
            if(dis[b]>dis[a]+w)
            {
                dis[b]=dis[a]+w;
                parent[b] = a;
                q.push({dis[b],b});
            }
        }
    }
    for(int i=1;i<=n;++i)
        if(dis[i]==inf)
        return false;
    return true;
}



int main(int argv, char* argc[])
{
    FASTIO


    int m;
    cin>>n>>m;

    rep(i,m)
    {
        int x,y;
        cin>>x>>y;
        add_edge_dj(x,y,1);
    }

    if(dijkstra(1))
    {
        cout<<"Yes\n";
        for(int i=2;i<=n;++i)
        cout<<parent[i]<<"\n";
    }
    else
        cout<<"No\n";

    return 0;
}


Measured memory_bytes: 13540