#include <algorithm>
#include <bitset>
#include <cmath>
#include <deque>
#include <functional>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <tuple>
#include <vector>

using namespace std;
using ll = int64_t;
using VL = vector<ll>;
using VD = vector<double>;
using VVL = vector<VL>;

#define FOR(i, start, end) for(ll i = (start), (i ## xxxx_end)=(end); i < (i ## xxxx_end); ++i)
#define FORD(i, start, end) for(ll i = (start), (i ## xxxx_end)=(end); i > (i ## xxxx_end); --i)
#define REP(i, n) FOR(i, 0, n)
#define REPD(i, n) FORD(i, n - 1, -1)

#define ALL(x) (x).begin(), (x).end()
#define SIZE(x) ((ll)(x).size())
#define MAX(x) *max_element(ALL(x))
#define MIN(x) *min_element(ALL(x))

template<class T, class U>bool chmax(T &a, const U &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T, class U>bool chmin(T &a, const U &b) { if (b<a) { a=b; return 1; } return 0; }

template <class T, class U>ostream &operator<<(ostream &o, const map<T, U>&obj) {o << "{"; for (auto &x : obj) o << " {" << x.first << " : " << x.second << "}" << ","; o << " }"; return o;}
template <class T>ostream &operator<<(ostream &o, const set<T>&obj) {o << "{"; for (auto itr = obj.begin(); itr != obj.end(); ++itr) o << (itr != obj.begin() ? ", " : "") << *itr; o << "}"; return o;}
template <class T>ostream &operator<<(ostream &o, const multiset<T>&obj) {o << "{"; for (auto itr = obj.begin(); itr != obj.end(); ++itr) o << (itr != obj.begin() ? ", " : "") << *itr; o << "}"; return o;}
template <class T>ostream &operator<<(ostream &o, const vector<T>&obj) {o << "{"; for (int i = 0; i < (int)obj.size(); ++i)o << (i > 0 ? ", " : "") << obj[i]; o << "}"; return o;}
template <class T, class U>ostream &operator<<(ostream &o, const pair<T, U>&obj) {o << "{" << obj.first << ", " << obj.second << "}"; return o;}
template <template <class tmp>  class T, class U> ostream &operator<<(ostream &o, const T<U> &obj) {o << "{"; for (auto itr = obj.begin(); itr != obj.end(); ++itr)o << (itr != obj.begin() ? ", " : "") << *itr; o << "}"; return o;}
void print(void) {cout << endl;}
template <class Head> void print(Head&& head) {cout << head;print();}
template <class Head, class... Tail> void print(Head&& head, Tail&&... tail) {cout << head << " ";print(forward<Tail>(tail)...);}

#define INF 1000000000000
#define MOD 10000007

ll N, M;
VVL AB;

void solve() {
    cin >> N >> M;
    AB = VVL(M, VL(2));
    for (auto &i : AB) cin >> i[0] >> i[1];
    VVL graph = VVL(N, VL());
    for (auto&& ab : AB) {
        const ll a = ab[0];
        const ll b = ab[1];
        graph[a - 1].push_back(b - 1);
        graph[b - 1].push_back(a - 1);
    }

    queue<ll> que = queue<ll>();
    que.push(0);
    VL preds = VL(N, -1);
    preds[0] = 0;
    while(!que.empty()) {
        ll current = que.front();
        que.pop();
        for(auto&& next : graph[current]) {
            if (preds[next] == -1) {
                preds[next] = current;
                que.push(next);
            }
        }
    }
    print("Yes");
    FOR(i, 1, N) {
        print(preds[i] + 1);
    }
}

int main() {
    solve();
    return 0;
}

Measured memory_bytes: 23444