#include <bits/stdc++.h>
#define rep(i, n) for (int i=0; i<n; i++)
using namespace std;
using Graph = vector<vector<int> >;

int main() {
    int N, M;
    cin >> N >> M;
    Graph G(N);
    rep(i, M) {
        int a, b;
        cin >> a >> b;
        G[a-1].push_back(b);
        G[b-1].push_back(a);
    }
    vector<int> sign(N, -1);
    queue<int> que;

    sign[0] = 0;
    que.push(1);

    while(!que.empty()) {
        int v = que.front();
        que.pop();

        for (auto nv : G[v-1]) {
            if (sign[nv-1] != -1) continue;

            sign[nv-1] = v;
            que.push(nv);
        }
    }
    rep(i, N) {
        if (sign[i] == -1) {
            cout << "No" << endl;
            return 0;
        }
    }
    cout << "Yes" << endl;
    for(int i = 1; i < N; i++) cout << sign[i] << endl;
  	return 0;
}