#include <stdio.h>

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

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

  int queue_init = 0;
  int queue_last = 0;
  int c_node = 0;
  for(int i = 0; i < n; i++){
    if(route[0][i] == 1){
      depth_node[queue_last] = i;
      sign[i] = 0;
      queue_last++;
    }
  }
  while(queue_init != queue_last){
    for(int i = queue_init, buf = queue_last; i != buf; i++){
      for(int j = 0; j <= n; j++){
        if(route[depth_node[i]][j] == 1 && sign[j] == -1){
          sign[j] = depth_node[i];

          if(queue_last == n-1){
            queue_last = 0;
            depth_node[0] = j;
          }else{
            queue_last++;
            depth_node[queue_last] = j;
          }
        }
      }
      printf("%d, %d\n", queue_init, queue_last);
      if(queue_init == n-1){
        queue_init = 0;
      }else{
        queue_init++;
      }
      if(i == n-1){
        i = -1;
      }
    }
  }
  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);
  }
}
