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

int main() {
  int n, m, a, b;
  int edges[200000][2];
  int length[100000] = {0};
  int destination[100000] = {0};
  int i, l;
  int rest;
  
  char str_n[7];
  char str_m[7];
  char str_a[7];
  char str_b[7];
  
  scanf("%s", str_n);
  scanf("%s", str_m);
  n = atoi(str_n);
  m = atoi(str_m);
  rest = n-1;
  
  for (i=0; i<m; i++) {
    scanf("%s", str_a);
    scanf("%s", str_b);
    a = atoi(str_a);
    b = atoi(str_b);
    edges[i][0] = a;
    edges[i][1] = b;
    
    if(a == 1) {
      length[b-1] = 1;
      destination[b-1] = 1;
      rest -= 1;
    }
    if(b == 1) {
      length[a-1] = 1;
      destination[a-1] = 1;
      rest -= 1;
    }
  }
  


  
  i = 1;
  while(rest > 0) {
    int pos[100000];
    int pos_length = 0;
    for (l=0; l<n; l++) {
      if(i == length[l]) {
        pos[pos_length] = l+1;
        pos_length += 1;
      }
    }
    
    for(l=0; l<pos_length+1; l++) {
      int edge_index;
      int p = pos[l];
      for(edge_index=0; edge_index<m; edge_index++) {
        a = edges[edge_index][0];
        b = edges[edge_index][1];
        if(a == p) {
          if(length[b-1] == 0) {
            length[b-1] = length[a-1]+1;
            destination[b-1] = a;
            rest -= 1;
          }
        }
        if(b == p) {
          if(length[a-1] == 0) {
            length[a-1] = length[b-1]+1;
            destination[a-1] = b;
            rest-= 1;
          }
        }

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