#include <iostream>
#include <iomanip>
#include <algorithm>
#include <vector>
#include <queue>
using namespace std;
int n, m;
vector< vector< int > > edg;
vector< int > d;
int main(void){
    cin >> n >> m;
    edg.assign(n+1, vector<int>());
    for(int i=0;i<m;i++){
        int a, b;
        cin >> a >> b;
        edg[a].push_back(b);
        edg[b].push_back(a);
    }
    d.assign(n+1, -1);
    d[1] = 0;
    queue<int> q;
    q.push(1);
    while(!q.empty()){
        int v = q.front();
        q.pop();
        for(int w: edg[v]) if(d[w] == -1){d[w] = v; q.push(w);}
    }
    puts("Yes");
    for(int i=2;i<=n;i++) cout << d[i] << endl;
}
