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

int main(){
  int n, m;  scanf("%d %d", &n, &m);
  int **graph;
  graph = (int **)malloc(sizeof(int*)*(n+5));
  for(int i=0; i<=n+1; i++)  graph[i] = (int *)malloc(sizeof(int)*(n+5));

  for(int i=0; i<m; i++){
    int a, b;  scanf("%d %d", &a, &b);
    graph[a][++graph[a][0]] = b;
    graph[b][++graph[b][0]] = a;
  }

  int visited[100005] = {0};
  visited[1] = 1;
  int ans[100005] = {0};
  int start = 0, end = 0;
  int will[200005] = {0};
  will[end++] = 1;
  while((end-start) != 0){
    int from = will[start];
    start = (start + 1) % 200005;
    for(int i=1; i<=graph[from][0]; i++){
      int to = graph[from][i];
      if(visited[to] == 0){
	visited[to] = 1;
	//	will[++will[0]] = to;
	will[end] = to;
	end = (end + 1) % 200005;
	ans[to] = from;
      }
    }
  }
  for(int i=2; i<=n; i++)
    if(ans[i] == 0){
      printf("No\n");
      return 0;
    }
  printf("Yes\n");
  for(int i=2; i<=n; i++){
    printf("%d\n", ans[i]);
  }  
  return 0;
}
