#include <algorithm>
#include <array>
#include <bitset>
#include <cassert>
#include <climits>
#include <cmath>
#include <cstdint>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <memory>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <valarray>
#include <vector>

#if __has_include(<string_view>)
#include <string_view>
#endif
#if __has_include(<optional>)
#include <optional>

template <class T>
constexpr const T& max(const T& a, const std::optional<T>& b)
{
    return b ? max(a, *b) : a;
}

template <class T>
constexpr const T& max(const std::optional<T>& a, const T& b)
{
    return a ? max(*a, b) : b;
}

template <class T>
constexpr const std::optional<T>& max(const std::optional<T>& a, const std::optional<T>& b)
{
    if (a && b)
        return *a > *b ? a : b;
    else if (a)
        return a;
    else
        return b;
}

template <class T>
constexpr const T& min(const T& a, const std::optional<T>& b)
{
    return b ? min(a, *b) : a;
}

template <class T>
constexpr const T& min(const std::optional<T>& a, const T& b)
{
    return a ? min(*a, b) : b;
}

template <class T>
constexpr const std::optional<T>& min(const std::optional<T>& a, const std::optional<T>& b)
{
    if (a && b)
        return *a < *b ? a : b;
    else if (a)
        return a;
    else
        return b;
}

#endif
#if __has_include(<any>)
#include <any>
#endif

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

using namespace std;

template <class T, class U>
istream& operator>>(istream& is, pair<T, U>& pair)
{
    is >> pair.first >> pair.second;
    return is;
}

template <class T>
istream& operator>>(istream& is, vector<T>& collection)
{
    for (auto& item : collection)
        is >> item;
    return is;
}

template <class T>
istream& operator>>(istream& is, valarray<T>& collection)
{
    for (auto& item : collection)
        is >> item;
    return is;
}

template <class T>
T peak_and_pop(std::queue<T>& q)
{
    assert(!q.empty());
    T t = move(q.front());
    q.pop();
    return t;
}

template <class T>
T peak_and_pop(std::priority_queue<T>& q)
{
    assert(!q.empty());
    T t = move(q.top());
    q.pop();
    return t;
}

template <class T>
T peak_and_pop(std::stack<T>& q)
{
    assert(!q.empty());
    T t = move(q.top());
    q.pop();
    return t;
}

struct room_t {
    int id = 0;
    int next = 0;
    optional<int64_t> distance;
    vector<int> neighbours;
};

void solution()
{
    int n, m;
    cin >> n >> m;
    vector<room_t> rooms(n+1);
    rep(i,n){
        rooms[i+1].id = i+1;
    }
    rep(i,m){
        int a,b;
        cin >> a >> b;
        rooms[a].neighbours.push_back(b);
        rooms[b].neighbours.push_back(a);
    }

    queue<room_t*> visit_queue;
    visit_queue.push(&rooms[1]);
    while(!visit_queue.empty()){
        room_t* room = peak_and_pop(visit_queue);
        const int d = *room->distance;
        for(int n : room->neighbours){
            room_t* nr = &rooms[n];
            if(nr->distance == nullopt){
                nr->distance = d + 1;
                nr->next = room->id;
                visit_queue.push(nr);
            }
        }
    }
    cout << "Yes\n";
    for(int i = 2; i <= n; ++i){
        cout << rooms[i].next << '\n';
    }
}

int main()
{
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout << fixed << setprecision(10);
    solution();
    return 0;
}


Measured memory_bytes: 12336