//#include<bits/stdc++.h>
#include<iostream>
#include<string>
#include<vector>
#include<utility>
#include<cmath>
#include<map>
#include<functional>
#include<queue>
#include<set>
#include<stack>
#include<iomanip>
#include<algorithm>
#include<unordered_map>
#include <numeric>
using namespace std;
using ll = long long;
#define rep(i,n) for(ll i=0;i<(n);i++)
template<typename T =ll> using v = vector<T>;
template<typename T =ll> using vv = v<v<T>>;
template<typename T =ll,typename U =ll> using p = pair<T,U>;
template<typename T> T chmin(T &a,T b) {return a=min(a,b);}
template<typename T> T chmax(T &a,T b) {return a=max(a,b);}
const ll INF = (ll)1e9;
template <int MOD>
struct ModInt {
    using lint = long long;
    int val;

    // constructor
    ModInt(lint v = 0) : val(v % MOD) {
        if (val < 0) val += MOD;
    };

    // unary operator
    ModInt operator+() const { return ModInt(val); }
    ModInt operator-() const { return ModInt(MOD - val); }
    ModInt inv() const { return this->pow(MOD - 2); }

    // arithmetic
    ModInt operator+(const ModInt& x) const { return ModInt(*this) += x; }
    ModInt operator-(const ModInt& x) const { return ModInt(*this) -= x; }
    ModInt operator*(const ModInt& x) const { return ModInt(*this) *= x; }
    ModInt operator/(const ModInt& x) const { return ModInt(*this) /= x; }
    ModInt pow(lint n) const {
        auto x = ModInt(1);
        auto b = *this;
        while (n > 0) {
            if (n & 1) x *= b;
            n >>= 1;
            b *= b;
        }
        return x;
    }

    // compound assignment
    ModInt& operator+=(const ModInt& x) {
        if ((val += x.val) >= MOD) val -= MOD;
        return *this;
    }
    ModInt& operator-=(const ModInt& x) {
        if ((val -= x.val) < 0) val += MOD;
        return *this;
    }
    ModInt& operator*=(const ModInt& x) {
        val = lint(val) * x.val % MOD;
        return *this;
    }
    ModInt& operator/=(const ModInt& x) { return *this *= x.inv(); }

    // compare
    bool operator==(const ModInt& b) const { return val == b.val; }
    bool operator!=(const ModInt& b) const { return val != b.val; }

    // I/O
    friend std::istream& operator>>(std::istream& is, ModInt& x) noexcept { return is >> x.val; }
    friend std::ostream& operator<<(std::ostream& os, const ModInt& x) noexcept { return os << x.val; }
};

constexpr int MOD = 1e9 + 7;
using mint = ModInt<MOD>;

void a(){
    ll N; cin >> N;
    if(N%10==2||N%10==4||N%10==5||N%10==7||N%10==9) cout << "hon" << endl;
    else if(N%10==0||N%10==1||N%10==6||N%10==8)cout << "pon"<<endl;
    else cout << "bon"<<endl;
}
void b(){
    ll K; cin >> K;
    string S; cin >> S;
    if(S.size()<=K) cout << S << endl;
    else{
        rep(i,K) cout << S[i];
        cout << "..."<<endl;
    }
}

void c(){
    double A,B,H,M; cin >> A >> B >> H >> M;
    double theta = abs((H/12+M/(12*60)-M/60)*2*M_PI);
    cout << fixed << setprecision(15) <<sqrt(A*A+B*B-2*A*B*cos(theta));
}

class d{
    struct edge{ll to,cost;};
    ll V;
    vv<edge> G;
    ll dist[(ll)1e5];
    ll prev[(ll)1e5];

    void dijkstra(ll s){
        priority_queue<p<>,v<p<>>,greater<p<>>>que;
        fill(dist,dist+V,INF);
        dist[s]=0;
        que.push(p<>(0,s));
        while(!que.empty()){
            p<> po = que.top(); que.pop();
            int v = po.second;
            if(dist[v]<po.first) continue;
            for(ll i=0;i<G[v].size();i++){
                edge e = G[v][i];
                if(dist[e.to]>dist[v]+e.cost){
                    dist[e.to]=dist[v]+e.cost;
                    que.push(p<>(dist[e.to],e.to));
                    prev[e.to] = v;
                }
            }
        }
    }

    public:
    d(){
        ll N,M; cin >> N >> M;
        V=N;
        G.resize(V);
        
        rep(i,M){
            ll A,B;cin >> A >> B;
            A--; B--;
            G[A].push_back(edge{B,1LL});
            G[B].push_back(edge{A,1LL});
        }
        fill(prev,prev+V,-1);
        dijkstra(0);

        for(ll i=1;i<N;i++){
            if(prev[i]==-1){
                cout << "No";
                return;
            }
        }
        cout << "Yes"<<endl;

        for(ll i=1;i<N;i++){
            cout << prev[i]+1 << endl;
        }

    }

};

void e(){

}
void f(){}
int main(){
    d();
    return 0;
}


Measured memory_bytes: 19400