#include <bits/stdc++.h>

using namespace std;

void solve(map<int, vector<int>> adj_rooms, vector<bool> checked, vector<int>& direction, int cur_room){
    vector<int> adj_r = adj_rooms[cur_room];

    bool end_loop = true;

    for (int j = 0; j < (int)adj_r.size(); j++){
        int selected_room = adj_r[j];
        if (!checked[selected_room]){
            end_loop = false;
            checked[selected_room] = true;
            direction[selected_room] = cur_room;
        }
    }

    if (end_loop)
        return;

    for (int j = 0; j < (int)adj_r.size(); j++){
        solve(adj_rooms, checked, direction, adj_r[j]);
    }

}

int main(){
    int N, M;
    cin >> N >> M;

    int A, B;
    map<int, vector<int>> adj_rooms;

    for (int i = 0; i < M; i++){
        cin >> A >> B;
        adj_rooms[A-1].push_back(B-1);
        adj_rooms[B-1].push_back(A-1);
    }

    for (int i = 0; i < N; i++){
        sort(adj_rooms[i].begin(), adj_rooms[i].end());
        adj_rooms[i].erase(unique(adj_rooms[i].begin(), adj_rooms[i].end()), adj_rooms[i].end());
    }

    vector<bool> checked(N);
    for (int i = 0; i < N; i++){
        checked[i] = false;
    }

    vector<int> direction(N);

    checked[0] = true;
    solve(adj_rooms, checked, direction, 0);

    cout << "Yes" << endl;
    for (int i = 1; i < N; i++){
        cout << direction[i]+1 << endl;
    }

    return 0;
}

