#include <bits/stdc++.h>
using namespace std;

int main(){
    cout<<"Yes"<<endl;
    long n,m;cin>>n>>m;
    vector<vector<int>> graph(n+1);
    for(int i=0;i<m;i++){
        int a,b;cin>>a>>b;
        graph[a].push_back(b);
        graph[b].push_back(a);
    }
    vector<int> prev(n+1,0);
    queue<int> q;
    q.push(1);
    while(q.size()!=0){
        int a=q.front();
        q.pop();
        for(int i=0;i<graph[a].size();i++){
            if(prev[graph[a][i]]==0){
                prev[graph[a][i]]=a;
                q.push(graph[a][i]);
            }
        }
    }
    for(int i=2;i<prev.size();i++)cout<<prev[i]<<endl;
}