//
//  main.cpp
//

#include <algorithm>
#include <array>
#include <assert.h>
#include <complex>
#include <iomanip>
#include <iostream>
#include <limits>
#include <map>
#include <math.h>
#include <memory>
#include <memory>
#include <queue>
#include <random>
#include <set>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <string>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
#include <vector>

using namespace std;

using ll = int64_t;
using ull = uint64_t;

[[maybe_unused]] constexpr ll LL_MAX = numeric_limits<ll>::max();
[[maybe_unused]] constexpr ll LL_MIN = numeric_limits<ll>::min();
[[maybe_unused]] constexpr ull ULL_MAX = numeric_limits<ull>::max();

#define rep(i, a, b) for (ll i = (a); i < (b); i++)
#define rrep(i, a, b) for (ll i = (a)-1; i >= (b); i--)

template <typename T>
void chmin(T& x, T y) {
    x = min(x, y);
}

template <typename T>
void chmax(T& x, T y) {
    x = max(x, y);
}

ll csum(ll x, ll y) {
    if (x > 0 && y > 0 && x > LL_MAX - y) {
        return LL_MAX;
    }
    if (x < 0 && y < 0 && x < LL_MIN - y) {
        return LL_MIN;
    }
    return x + y;
}

template<typename T>
vector<T> make_vec_nd(T init, ll size) {
	return vector<T>(size, init);
}
template<typename T, typename... Args>
auto make_vec_nd(T init, ll size, Args... rest) {
	auto inner = make_vec_nd(init, rest...);
	return vector<decltype(inner)>(size, inner);
}

struct ListCostGraph {
    struct Edge {
        ll from;
        ll to;
        ll cost;
    };
    vector<vector<Edge>> edges;
    
    ListCostGraph(ll size) { edges.resize(size); }
    
    void add_edge(ll from, ll to, ll cost) {
        edges[from].push_back(Edge{from, to, cost});
    }
    
    void add_edge_bidir(size_t a, size_t b, ll cost) {
        add_edge(a, b, cost);
        add_edge(b, a, cost);
    }
    
    vector<ll> dijkstra(ll s) {
        // O(E logV)
        vector<ll> dist(edges.size(), numeric_limits<ll>::max());
        struct P {
            size_t vertex;
            ll distance;
            P(size_t vertex, ll distance)
            : vertex(vertex)
            , distance(distance) {}
        };
        auto compare = [](const P& lhs, const P& rhs) {
            return lhs.distance > rhs.distance;
        };
        priority_queue<P, vector<P>, decltype(compare)> que(compare);
        dist[s] = 0;
        que.push(P(s, 0));
        while (!que.empty()) {
            P p = que.top();
            que.pop();
            size_t v = p.vertex;
            ll d = p.distance;
            if (dist[v] < d) {
                continue;
            }
            for (int i = 0; i < edges[v].size(); i++) {
                const Edge& e = edges[v][i];
                ll new_dist = dist[v] + e.cost;
                if (dist[e.to] <= new_dist) {     // eを使っても最短経路が改善しないとき
                    continue;
                }
                dist[e.to] = new_dist;
                que.push(P(e.to, new_dist));
            }
        }
        return dist;
    }
};

int main() {
    ll N, M;
    cin >> N >> M;
    ListCostGraph graph(N);
    rep(i,0,M) {
        ll A, B;
        cin >> A >> B;
        A--;
        B--;
        graph.add_edge_bidir(A, B, 1);
    }
    auto dist = graph.dijkstra(0);
    cout << "Yes" << endl;
    rep(i,1,N) {
        for (ListCostGraph::Edge& e : graph.edges[i]) {
            if (dist[e.to] == dist[i] - 1) {
                cout << e.to + 1 << endl;
                break;
            }
        }
    }
}


Measured memory_bytes: 22660