#include <stdio.h>

int main(){
  int n, m;
  scanf("%d %d", &n, &m);
  int route[m*2 + 1][2];
  int route_first[n];
  int sign[n];
  int depth_node[n];
  for(int i = 0; i < n; i++){
    sign[i] = -1;
    depth_node[i] = -1;
    route_first[i] = 0;
  }
  sign[0] = 0;

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

  int queue_init = 0;
  int queue_last = 0;
  int c_node = 0;
  depth_node[queue_init] = 0;
  int t;
  while(queue_init <= queue_last){
    c_node = depth_node[queue_init];
    t = route_first[c_node];
    while(t != 0){
      if(sign[route[t][0]] == -1){
        queue_last++;
        depth_node[queue_last] = route[t][0];
        sign[route[t][0]] = c_node;
      }
      t = route[t][1];
    }
    queue_init++;
    //printf("%d, %d\n", queue_init, queue_last);
  }
  for(int i = 1; i < n; i++){
    if(sign[i] == -1){
      printf("no\n");
      return 0;
    }
  }

  printf("Yes\n");
  for(int i = 1; i < n; i++){
    printf("%d\n", sign[i] + 1);
  }
  return 0;
}
