// Slower C++ solution:
#include "bits/stdc++.h"

#define rep(i, j) for (int i = 0; i < j; i++)

using namespace std;

using ll = long long;



const int INF = 1001001001;



/*struct mint {

    ll x; // typedef long long ll;

    mint(ll x = 0) :x((x% mod + mod) % mod) {}

    mint operator-() const { return mint(-x); }

    mint& operator+=(const mint a) {

        if ((x += a.x) >= mod) x -= mod;

        return *this;

    }

    mint& operator-=(const mint a) {

        if ((x += mod - a.x) >= mod) x -= mod;

        return *this;

    }

    mint& operator*=(const mint a) { (x *= a.x) %= mod; return *this; }

    mint operator+(const mint a) const { return mint(*this) += a; }

    mint operator-(const mint a) const { return mint(*this) -= a; }

    mint operator*(const mint a) const { return mint(*this) *= a; }

    mint pow(ll t) const {

        if (!t) return 1;

        mint a = pow(t >> 1);

        a *= a;

        if (t & 1) a *= *this;

        return a;

    }



    // for prime mod

    mint inv() const { return pow(mod - 2); }

    mint& operator/=(const mint a) { return *this *= a.inv(); }

    mint operator/(const mint a) const { return mint(*this) /= a; }

};

istream& operator>>(istream & is, const mint & a) { return is >> a.x; }

ostream& operator<<(ostream & os, const mint & a) { return os << a.x; }*/



vector<int> to[100005];



int main() {

    int n, m;

    cin >> n >> m;

    rep(i, m) {

        int a, b;

        cin >> a >> b;

        a--; b--;

        to[a].emplace_back(b);

        to[b].emplace_back(a);

    }

    

    queue<int> q;

    vector<int> dist(n, INF);

    vector<int> pre(n, -1);

    dist[0] = 0;

    q.push(0);

    while (!q.empty()) {

        int v = q.front(); q.pop();

        for (int u : to[v]) {

            if (dist[u] != INF) continue;

            dist[u] = dist[v] + 1;

            pre[u] = v;

            q.push(u);

        }

    }



    cout << "Yes" << endl;

    rep(i, n) {

        if (i == 0) continue;

        int ans = pre[i];

        ans++;

        cout << ans << endl;

    }

    return 0;

}


// Faster C++ solution for the same problem (measured speedup: 3.493842666601102x):
#include "bits/stdc++.h"

#define rep(i, j) for (int i = 0; i < j; i++)

using namespace std;

using ll = long long;

using P = pair<int, int>;

using ull = unsigned long long;



ll gcd(ll x, ll y);

int fac(ll n, vector<int> num);



const int INF = 1001001001;



//mint�p�̕ϐ� (10��9��)

const int mod = 1000000007;



struct mint {

    ll x; // typedef long long ll;

    mint(ll x = 0) :x((x% mod + mod) % mod) {}

    mint operator-() const { return mint(-x); }

    mint& operator+=(const mint a) {

        if ((x += a.x) >= mod) x -= mod;

        return *this;

    }

    mint& operator-=(const mint a) {

        if ((x += mod - a.x) >= mod) x -= mod;

        return *this;

    }

    mint& operator*=(const mint a) { (x *= a.x) %= mod; return *this; }

    mint operator+(const mint a) const { return mint(*this) += a; }

    mint operator-(const mint a) const { return mint(*this) -= a; }

    mint operator*(const mint a) const { return mint(*this) *= a; }

    mint pow(ll t) const {

        if (!t) return 1;

        mint a = pow(t >> 1);

        a *= a;

        if (t & 1) a *= *this;

        return a;

    }



    // for prime mod

    mint inv() const { return pow(mod - 2); }

    mint& operator/=(const mint a) { return *this *= a.inv(); }

    mint operator/(const mint a) const { return mint(*this) /= a; }

};

istream& operator>>(istream & is, const mint & a) { return is >> a.x; }

ostream& operator<<(ostream & os, const mint & a) { return os << a.x; }



int main() {

    int n, m;

    cin >> n >> m;

    vector<vector<int> > miti(n, vector<int> (0));

    rep(i, m) {

        int a, b;

        cin >> a >> b;

        a--; b--;

        miti[a].emplace_back(b);

        miti[b].emplace_back(a);

    }



    queue<int> room;

    room.push(0);

    vector<int> ans(n, -1);

    while (!room.empty()) {

        int cu = room.front(); room.pop();

        for (int i : miti[cu]) {

            if (ans[i] != -1) continue;

            ans[i] = cu;

            room.push(i);

        }

    }



    cout << "Yes" << endl;

    rep(i, n) {

        if (i == 0) continue;

        cout << ans[i] + 1 << endl;

    }

    return 0;

}



/*���C�u�����ő����*/

//���[�O���b�h�̌ݏ��@

ll gcd(ll x, ll y) {

    ll num[3];

    num[0] = (x > y) ? x : y;

    num[1] = (x <= y) ? x : y;

    num[2] = num[0] % num[1];



    while (num[2]) {

        num[0] = num[1];

        num[1] = num[2];

        num[2] = num[0] % num[1];

    }



    return num[1];

}



/*�f��������*/

//���색�C�u����

int fac(ll n, vector<int> num) {

    ll kazu = n;

    for (int i = 2; i <= sqrt(n); i++) {

        while (1) {

            if (kazu % i != 0) break;



            kazu /= i;

            num[i]++;

        }

    }

    if (kazu == n && n != 1) return 1;

    int ans = 0;

    if (kazu != 1) ans++;

    for (int i = 2; i <= sqrt(n); i++) {

        for (int j = 1; j <= num[i]; j++) {

            num[i] -= j;

            ans++;

        }

    }

    return ans;

}