#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll zero = 0;
const ll INF = 10000000000000000; //10^16
const ll MOD = 1000000007; //10^9+7
const ll MOD2 = 998244353;

int main(){
    int N,M;
    cin >> N >> M;
    vector<vector<int>> graph(N+1);
    int tmp1,tmp2;
    for (int i = 0; i < M; i++) {
        cin >> tmp1 >> tmp2;
        graph[tmp1].push_back(tmp2);
        graph[tmp2].push_back(tmp1);
    }

    queue<int> bfs;
    vector<int> ans(N+1,-1);
    ans[1] = 0;
    bfs.push(1);
    int tmp;
    while(!bfs.empty()){
        tmp = bfs.front();
        bfs.pop();
        for(int i : graph.at(tmp)){
            if(ans[i] != -1){
                continue;
            }
            else{
                ans[i] = tmp;
                bfs.push(i);
            }
        }
    }

    printf("Yes\n");
    for(int i = 2; i <= N; i++){
        printf("%d\n", ans[i]);
    }


}