#include <bits/stdc++.h>
#define INF 99999999
using namespace std;
int main(){
	int N,M,a,b,dis = 0,v;
  cin >> N >> M;
  vector<vector<int>> vec(N);
  vector<int> light(N,INF);
  light.at(0) = 0;
  queue<int> q;
  for(int i = 0;i < M;i++){
	cin >> a >> b;
    vec.at(a - 1).push_back(b - 1);
    vec.at(b - 1).push_back(a - 1);
  }
	q.push(0);
  while(!q.empty()){
    v = q.front();
    q.pop();
    for(int c : vec[v]){
      if(light.at(c) != INF) continue;
   	
     light.at(c) = v;
      q.push(c);
    }
  }
  cout << "Yes" << endl;
  for(int i = 1;i < N;i++){
    cout << light[i] + 1 << endl;
  }
return 0;
}