#if 1   // use_templates

#define _CRT_SECURE_NO_WARNINGS
#define _USE_MATH_DEFINES

#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <vector>
#include <string>
#include <stack>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <algorithm>
using namespace std;

typedef long long ll;
typedef unsigned long long ull;

#define rep(i, up) for (ll i = 0; i < up; ++i)
#define repp(i, up) for (ll i = 0; i <= up; ++i)
#define rrep(i, lo, up) for (ll i = lo; i < up; ++i)
#define rrepp(i, lo, up) for (ll i = lo; i <= up; ++i)
#define eep(i, lo, up) for ((i) = (lo); (i) < (up); ++(i))
#define eepp(i, lo, up) for ((i) = (lo); (i) <= (up); ++(i))

#define rdi(i) ll i; scanf("%lld", &i)
#define rds(s) string s; cin >> s
#define rdc(c) char c; cin >> c

#define INF 10000000000
#define MOD 1000000007


ll gcd(ll a, ll b);
template<class T>
auto fast_pow(T a, ll n);


template<class T, T n>
struct mod_t
{
    static_assert(n > 0, "invalid divisor");

    T value;

    constexpr mod_t() : value() { }
    constexpr mod_t(T x) : value(normalize(x)) { }

    constexpr operator T() const {
        return value;
    }
    constexpr auto operator+(mod_t<T, n> right) const {
        return mod_t<T, n> { (value + right.value) % n };
    }
    constexpr auto& operator+=(mod_t<T, n> right) {
        return *this = *this + right;
    }
    constexpr auto operator-(mod_t<T, n> right) const {
        return mod_t<T, n> { (value - right.value + n) % n };
    }
    constexpr auto& operator-=(mod_t<T, n> right) {
        return *this = *this - right;
    }
    constexpr auto operator*(mod_t<T, n> right) const {
        return mod_t<T, n> { (value * right.value) % n };
    }
    constexpr auto& operator*=(mod_t<T, n> right) {
        return *this = *this * right;
    }
    constexpr auto operator/(mod_t<T, n> right) const {
        return *this * right.pow(n - 2);
    }
    constexpr auto& operator/=(mod_t<T, n> right) {
        return *this = *this / right;
    }
    constexpr auto pow(ll nn) const {
        return fast_pow(*this, nn);
    }
    constexpr auto inv() const {
        return pow(n - 2);
    }

    static constexpr auto normalize(T x) {
        if (x < 0) {
            return (n + x % n) % n;
        } else {
            return x % n;
        }
    }
};
template<class T, T n>
auto& operator>>(istream& in, mod_t<T, n>& out) {
    T tmp;
    in >> tmp;
    out.value = mod_t<T, n>::normalize(tmp);
    return in;
}
template<class T, T n>
auto& operator<<(ostream& out, mod_t<T, n> val) {
    out << val.value;
    return out;
}
typedef mod_t<ll, MOD> mod;

template<class T, T n>
class combi_t
{
    using value_t = mod_t<T, n>;

    vector<value_t> factn;
    vector<value_t> ifactn;

    ll maxn;

public:
    combi_t() : factn(0), ifactn(0), maxn(0) { }

    combi_t(ll maxn)
        : factn(maxn + 1)
        , ifactn(maxn + 1)
    {
        init(maxn);
    }

    void init(ll maxn) {
        factn.resize(maxn + 1);
        ifactn.resize(maxn + 1);

        this->maxn = maxn;
        factn[0] = 1;
        ifactn[0] = 1;
        for (ll i = 1; i <= maxn; ++i) {
            factn[i] = i * factn[i - 1];
            ifactn[i] = value_t(i).inv() * ifactn[i - 1];
        }
    }

    constexpr auto combi(ll a, ll b) const {
        if (b <= 0 || a - b <= 0) {
            return value_t(1);
        } else {
            return factn[a] * ifactn[b] * ifactn[a - b];
        }
    }

    constexpr auto perm(ll a, ll b) const {
        return factn[a] * ifactn[a - b];
    }

    constexpr auto operator()(ll a, ll b) const {
        return combi(a, b);
    }
};
#define USE_COMBI(maxn) combi_t<ll, MOD> combi(maxn);

template<class T>
auto fast_pow(T a, ll n) {
    if (n <= 0) {
        return T(1);
    } else if (n == 1) {
        return T(a);
    } else if (n % 2 == 0) {
        auto work = fast_pow(a, n / 2);
        return work * work;
    } else {
        return fast_pow(a, n - 1) * a;
    }
}

ll gcd(ll a, ll b)
{
    if (a < b) {
        return gcd(b, a);
    }
    ll r;
    while (r = a % b) {
        a = b;
        b = r;
    }
    return b;
}

template<class T>
void read_vec(vector<T>& v, ll n)
{
    v.resize(n);
    for (ll i = 0; i < n; ++i) {
        cin >> v[i];
    }
}
template<>
void read_vec<ll>(vector<ll>& v, ll n) {
    v.resize(n);
    for (ll i = 0; i < n; ++i) {
        scanf("%lld", &v[i]);
    }
}
template<class T>
auto read_vec(ll n) {
    vector<T> result;
    read_vec(result, n);
    return result;
}
void read_idxs(vector<ll>& v, ll n) {
    v.resize(n);
    for (ll i = 0; i < n; ++i) {
        scanf("%lld", &v[i]);
        --v[i];
    }
}
auto read_idxs(ll n) {
    vector<ll> result(n);
    for (ll i = 0; i < n; ++i) {
        scanf("%lld", &result[i]);
        --result[i];
    }
    return result;
}
template<class T>
void read_mat(vector<vector<T>>& v, ll n, ll m) {
    v.resize(n);
    for (ll i = 0; i < n; ++i) {
        read_vec(v[i], m);
    }
}
template<class T>
auto read_mat(ll n, ll m) {
    vector<T> result(n);
    for (ll i = 0; i < n; ++i) {
        read_vec(result[i], m);
    }
    return result;
}

#endif  // end of use_templates

int main()
{
    ll n, m;
    cin >> n >> m;
    vector<vector<ll>> vs(n);
    vector<bool> visited(n, false);
    vector<ll> result(n, -1);
    rep(i, m) {
        ll a, b;
        cin >> a >> b;
        --a; --b;
        vs[a].push_back(b);
        vs[b].push_back(a);
    }
    queue<pair<ll, pair<ll, ll>>> que;
    que.push(pair<ll, pair<ll, ll>>(0, pair<ll, ll>(0, -1)));
    while (!que.empty()) {
        auto item = que.front();
        que.pop();
        auto node = item.first;
        auto dist = item.second.first;
        auto from = item.second.second;
        if (visited[node]) {
            continue;
        }
        visited[node] = true;
        result[node] = from;
        rep(i, vs[node].size()) {
            if (!visited[vs[node][i]]) {
                que.push(pair<ll, pair<ll, ll>>(vs[node][i], pair<ll, ll>(dist + 1, node)));
            }
        }
    }
    rrep(i, 1, n) {
        if (result[i] < 0) {
            cout << "No" << endl;
            return 0;
        }
    }
    cout << "Yes" << endl;
    rrep(i, 1, n) {
        cout << result[i] + 1 << endl;
    }
    return 0;
}


Measured memory_bytes: 14524