#include <stdio.h>

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

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

  int queue_init = 0;
  int queue_last = 0;
  int c_node = 0;
  for(int i = 0; i < m; i++){
    if(route[i][1] == 0){
      depth_node[queue_last] =  route[i][2];
      sign[route[i][2]] = 0;
      queue_last++;
    }else if(route[i][2] == 0){
      depth_node[queue_last] =  route[i][1];
      sign[route[i][1]] = 0;
      queue_last++;
    }
  }
  while(queue_init != queue_last){
    c_node = depth_node[queue_init];
    for(int i = 0; i <= m; i++){
      if(route[i][1] == c_node && sign[route[i][2]] == -1){
        depth_node[queue_last] = route[i][2];
        sign[route[i][2]] = c_node;
        queue_last++;
      }else if(route[i][2] == c_node && sign[route[i][1]] == -1){
        depth_node[queue_last] = route[i][1];
        sign[route[i][1]] = c_node;
        queue_last++;
      }
    }
    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;
}
