#include <stdio.h>
#include <stdlib.h>

int main(){
  int n, m;  scanf("%d %d", &n, &m);
  int **graph;
  graph = (int**)malloc(sizeof(int*)*(n+22));
  for(int i=0; i<n+22; i++)
    graph[i] = malloc(sizeof(int)*(m+22));
  while(m--){
    int a, b;  scanf("%d %d", &a, &b);
    graph[a][++graph[a][0]] = b;
    graph[b][++graph[b][0]] = a;
  }

  int ans[100005] = {0}, anscount = 0;  ans[1] = 1;
  int queue[100000], front = 0, rear = 0, qsize = 100000;
  queue[rear++] = 1;
  while(front != rear){
    int now = queue[front];  front = (front+1)%qsize;
    for(int i=1; i<=graph[now][0]; i++)
      if(!ans[graph[now][i]]){
	ans[graph[now][i]] = now;
	queue[rear] = graph[now][i];
	rear = (rear+1)%qsize;
	anscount++;
      }
  }

  if(anscount != n-1){
    printf("No\n");
  }else{
    printf("Yes\n");
    for(int i=2; i<=n; i++)
      printf("%d\n", ans[i]);
  }

  return 0;
}
