#include<iostream>
#include<vector>
#include<queue>
using namespace std;

int main(){
    int n, m;
    cin >> n >> m;
    vector<int> v[n];
    while(m--){
        int a, b;
        cin >> a >> b;
        a--, b--;
        v[a].push_back(b);
        v[b].push_back(a);
    }
    vector<int> ret(n, -1);
    queue<int> q;
    q.push(0);
    while(!q.empty()){
        int x = q.front();  q.pop();
        for(int y : v[x]){
            if(ret[y]==-1){
                ret[y] = x;
                q.push(y);
            }
        }
    }
    cout << "Yes" << endl;
    for(int i = 1; i < n; i++)  cout << ret[i]+1 << endl;
    return 0;
}