#include <iostream>
#include <iomanip>
#include <algorithm>
#include <bitset>
#include <map>
#include <set>
#include <vector>
#include <list>
#include <queue>
#include <sstream>
#include <cmath>
#include <functional>
#include <climits>
using namespace std;

#define rep(i,n) for(int i=0;i<n;i++)
#define reps(s,i,n) for(int i=s;i<n;i++)
#define rev(i,n) for(int i=n-1;i>=0;i--)
#define skip(i,n,p) for(int i=0;i<n;i+=p)
#define all(a)  (a).begin(),(a).end()
#define int64 long long
#define debug cerr << __FILE__ << ":" << __LINE__ << endl;
#define INF 2147483647

struct Init {
    Init() {
        cin.tie(0);
        ios::sync_with_stdio(false);
        cout.precision(20);
        cout << fixed;
        // setw(6) << setfill('0')
    }
} init;

template <typename _Ty>
ostream& operator << (ostream& ostr, const vector<_Ty>& v) {
    for(int i = 0; i < (int) v.size(); i++) {
        ostr << v[i] << (i + 1 != v.size() ? " " : "");
    }
    return ostr;
}

template <typename _K, typename _V>
ostream& operator << (ostream& ostr, const map<_K, _V>& v) {
    ostr << "{";
    for (auto iter = v.begin(); iter != v.end(); ++iter) {
        ostr << (*iter).first << ": " << (*iter).second << ", ";
    }
    ostr << "}";
    return ostr;
}

template <typename _K>
ostream& operator << (ostream& ostr, const set<_K>& v) {
    for (auto iter = v.begin(); iter != v.end(); ++iter) {
        ostr << *iter << (iter != v.end() ? " " : "");
    }
    return ostr;
}

template <typename _K, typename _V>
ostream& operator << (ostream& ostr, const pair<_K, _V>& v) {
    ostr << v.first << " " << v.second;
    return ostr;
}

int64 powmod(int64 n, int64 count, int64 mod) {
    if (count == 0) return 1;
    if (count % 2 == 0) {
        int64 t = powmod(n, count / 2, mod);
        return t * t % mod;
    }
    return n * powmod(n, count - 1, mod) % mod;
}

int64 ncr(int64 n, int64 r, int64 mod) {
    int64 a;
    if (n < r) a = min(n, r - n);
    else a = min(n - r, r);

    int64 res = 1;
    rep(i, a) {
        res = res * (n - i) % mod;
        res = res * powmod(i + 1, mod - 2, mod) % mod;
    }

    return res;
}

int main() {
    int N, M; cin >> N >> M;
    vector<pair<int, int>> L(M);
    rep(i, M) {
        cin >> L[i].first >> L[i].second;
    }

    map<int, set<int>> V;
    rep(i, M) {
        auto v = L[i];

        V[v.first-1].insert(v.second-1);
        V[v.second-1].insert(v.first-1);
    }

    // for (auto v : V) {
    //     cout << v.first << ": " << v.second << endl;
    // }

    if (V[0].empty()) {
        cout << "No" <<  endl;
        exit(0);
    }

    map<int, set<int>> next;
    next[0] = V[0];

    vector<int> ans(N, -1);
    vector<bool> al(N, false);
    while(!next.empty()) {
        auto tmp = next;
        next = map<int, set<int>>();

        for (auto v : tmp) {
            for (auto v2 : v.second) {
                if (ans[v2] == -1) ans[v2] = v.first+1;
            }
            al[v.first] = true;
        }

        // cout << endl;
        // cout << "-----" << endl;
        // cout << ans << endl;

        for (auto v : tmp) {
            for (auto v2 : v.second) {
                if (!al[v2]) {
                    for (auto v3: V[v2]) {
                        if (!al[v3]) {
                            next[v2].insert(v3);
                        }
                    }
                }
            }
        }

        // cout << next << endl;
    }

    reps(1, i, N) {
        if (ans[i] == -1) {
            cout << "No" <<  endl;
            exit(0);
        }
    }

    cout << "Yes" <<  endl;
    reps(1, i, N) {
        cout << ans[i] << endl;
    }
}


Measured memory_bytes: 67956