#include<iostream>
#include<vector>
#include<string>
#include<map>
#include<queue>
#include<set>
#include<cmath>
#include<stack>
#include<random>
#include<iterator>
#include <algorithm>
#include <functional>
#include <cassert>
using namespace std;

template <typename T>
void printvec(vector<T> v)
{
    for(auto it=v.begin();it != v.end();it++)
    {
        cout << (*it) << endl;
    }
    cout << endl;
}


struct ListNode {
    int val;
    ListNode *next;
    ListNode() : val(0), next(nullptr) {}
    ListNode(int x) : val(x), next(nullptr) {}
    ListNode(int x, ListNode *next) : val(x), next(next) {}
};


void printl(ListNode* l){
    ListNode *h;h=l;
    while(h!= NULL){
        cout << h->val<< endl;
        h = h->next;
    }
}

template <typename T>
void chmax(T& a,const T& b){if(b > a)a = b;}
template<typename T>
void chmin(T& a ,const T& b){if(a > b)a = b;}

int lower_bound(vector<int> v,int k){//vの中でk以下の値をみっけるないときは一番いひだりが帰ってくる
    int l(0),r(v.size());
    long long int mid;
    while(l<r){
        mid = (l+r)/2;
        if(mid == v.size() -1 ){
            return v.size()-1;
        }
        if(v[mid] <= k && v[mid+1] >k ){
            return mid;
        }else if(v[mid] > k){
            r = mid-1;
        }else{
            l = mid + 1;
        }
    }
    return l;
}
template <typename T>
void print2dvec(vector<vector<T>> v){
    for(int j=0;j<v[0].size();j++)
    {
        for(int i=0;i<v.size();i++){
            cout << v[i][j];
        }
        cout << endl;
    }
    
}


int lcs(string s1,string s2){
    int dp[50][50] = {0};
    cout << dp[2][2] << endl;
    //i,jは何文字目か
    for(int i=1;i<=s1.size();i++){
        for(int j = 1;j<=s2.size();j++){
            if(s1[i-1] ==s2[j-1] ){
                chmax(dp[i][j] , dp[i-1][j-1] + 1);
            }
            chmax(dp[i][j],dp[i-1][j]);
            chmax(dp[i][j] , dp[i][j-1]);
        }
    }
    return dp[s1.size()][s2.size()];
}


struct veccomp{
    bool operator()(const vector<int>& a,const vector<int>& b)const{
        return a[0] < b[0];
    }
};    
//部屋1からの距離
//



int main(){
    int n,m;//n : 部屋数
    cin >> n >> m;
    vector<vector<int>> M;
    M.resize(n + 1);
    int d1,d2;
    for(int i=0;i<m;i++){
        cin >> d1 >> d2;
        M[d1].push_back(d2);
        M[d2].push_back(d1);
    }
    
    vector<int > parent;
    vector<int> color;
    color.resize(n + 1);
    parent.resize(n + 1);
    for(int i=1;i<=n;i++){
        color[i] = 0;
        parent[i] = -1;
    }
    queue<int> q;
    q.push(1);
    color[1] = 1;
    int place;
    while(true){
        if(q.size() == 0){
            break;
        }
        place = q.front();
        q.pop();
        for (int i=0;i<M[place].size();i++){
            if(color[M[place][i]] == 0){
                q.push(M[place][i]);
                parent[M[place][i]] = place;
                color[M[place][i]] = 1;
            }
        }
    }
    vector<int> ans(parent.begin() + 2,parent.end());
    bool flag;
    flag = true;
    for(int i=0;i<ans.size();i++){
        if(ans[i] == -1){
            cout << "No" << endl;
            flag = false;
            break;
        }
    }
    if(flag){
        cout << "Yes" << endl;
        printvec(ans);}
    return 0;

}


Measured memory_bytes: 11448