#include<stdio.h>
#include<stdlib.h>
#define rep(i,n) for(int (i) = 0; i < (int)(n); (i)++)
#define rep2(i, k, n) for(int (i) = (k); i < (int)(n); (i)++)

#define N 100000

/*リスト一式*/
/*NDDTQQQで置換する型を変更してリストのデータを指定*/
/*複数使う場合はQQQをアルファベットで置換*/
typedef int NDDTQQQ;
typedef struct listElementQQQ{
  NDDTQQQ data;
  struct listElementQQQ *next;
  struct listElementQQQ *prev;
} LIELQQQ;
typedef struct listQQQ{
  int size;
  LIELQQQ *front;
  LIELQQQ *back;
} LISTQQQ;
LIELQQQ *new_listElement_QQQ(NDDTQQQ d){
  LIELQQQ *ret = (LIELQQQ *)malloc(sizeof(LIELQQQ));
  ret->data = d;
  ret->next = NULL;
  ret->prev = NULL;
  return ret;
}
void new_list_QQQ(LISTQQQ *list){
  list->back = NULL;
  list->front = NULL;
  list->size = 0;
}
void push_back_QQQ(NDDTQQQ d, LISTQQQ *list){
  LIELQQQ *new = new_listElement_QQQ(d);
  if(list->size == 0){
    list->front = list->back = new;
  }else{
    list->back->next = new;
    new->prev = list->back;
    list->back = new;
  }
  list->size++;
}
void push_front_QQQ(NDDTQQQ d, LISTQQQ *list){
  LIELQQQ *new = new_listElement_QQQ(d);
  if(list->size == 0){
    list->front = list->back = new;
  }else{
    list->front->prev = new;
    new->next = list->front;
    list->front = new;
  }
  list->size++;
}
int pop_back_QQQ(LISTQQQ *list){
  if(list == NULL || list->size == 0){
    return 1;
  }
  if(list->size == 1){
    free(list->back);
    list->front = list->back = NULL;
    list->size = 0;
    return 0;
  }
  LIELQQQ *bk = list->back;
  LIELQQQ *nbk = bk->prev;
  free(bk);
  nbk->next = NULL;
  list->back = nbk;
  list->size--;
  return 0;
}
int pop_front_QQQ(LISTQQQ *list){
  if(list == NULL || list->size == 0){
    return 1;
  }
  if(list->size == 1){
    free(list->back);
    list->front = list->back = NULL;
    list->size = 0;
    return 0;
  }
  LIELQQQ *fr = list->front;
  LIELQQQ *nfr = fr->next;
  free(fr);
  nfr->prev = NULL;
  list->front = nfr;
  list->size--;
  return 0;
}
/*ここまでリスト一式*/

/*リスト一式*/
/*NDDTLLLで置換する型を変更してリストのデータを指定*/
/*複数使う場合はLLLをアルファベットで置換*/
typedef int NDDTLLL;
typedef struct listElementLLL{
  NDDTLLL data;
  struct listElementLLL *next;
  struct listElementLLL *prev;
} LIELLLL;
typedef struct listLLL{
  int size;
  LIELLLL *front;
  LIELLLL *back;
} LISTLLL;
LIELLLL *new_listElement_LLL(NDDTLLL d){
  LIELLLL *ret = (LIELLLL *)malloc(sizeof(LIELLLL));
  ret->data = d;
  ret->next = NULL;
  ret->prev = NULL;
  return ret;
}
void new_list_LLL(LISTLLL *list){
  list->back = NULL;
  list->front = NULL;
  list->size = 0;
}
void push_back_LLL(NDDTLLL d, LISTLLL *list){
  LIELLLL *new = new_listElement_LLL(d);
  if(list->size == 0){
    list->front = list->back = new;
  }else{
    list->back->next = new;
    new->prev = list->back;
    list->back = new;
  }
  list->size++;
}
void push_front_LLL(NDDTLLL d, LISTLLL *list){
  LIELLLL *new = new_listElement_LLL(d);
  if(list->size == 0){
    list->front = list->back = new;
  }else{
    list->front->prev = new;
    new->next = list->front;
    list->front = new;
  }
  list->size++;
}
int pop_back_LLL(LISTLLL *list){
  if(list == NULL || list->size == 0){
    return 1;
  }
  if(list->size == 1){
    free(list->back);
    list->front = list->back = NULL;
    list->size = 0;
    return 0;
  }
  LIELLLL *bk = list->back;
  LIELLLL *nbk = bk->prev;
  free(bk);
  nbk->next = NULL;
  list->back = nbk;
  list->size--;
  return 0;
}
int pop_front_LLL(LISTLLL *list){
  if(list == NULL || list->size == 0){
    return 1;
  }
  if(list->size == 1){
    free(list->back);
    list->front = list->back = NULL;
    list->size = 0;
    return 0;
  }
  LIELLLL *fr = list->front;
  LIELLLL *nfr = fr->next;
  free(fr);
  nfr->prev = NULL;
  list->front = nfr;
  list->size--;
  return 0;
}
/*ここまでリスト一式*/

const int INF = 1001001001;

int main(void){
  int n, m;
  scanf("%d%d", &n, &m);
  LISTLLL gr[N];
  rep(i, n){
    new_list_LLL(&gr[i]);
  }
  rep(i, m){
    int a, b;
    scanf("%d%d", &a, &b);
    a--; b--;
    push_back_LLL(b, &gr[a]);
    push_back_LLL(a, &gr[b]);
  }
  int chk[N];
  rep(i, n) chk[i] = INF;
  LISTQQQ queue;
  new_list_QQQ(&queue);
  chk[0] = 0;
  push_front_QQQ(0, &queue);
  while(queue.size != 0){
    int now = queue.back->data; pop_back_QQQ(&queue);
    for(LIELLLL *p = gr[now].front; p != NULL; p = p->next){
      if(chk[p->data] != INF) continue;
      chk[p->data] = now;
      push_front_QQQ(p->data, &queue);
    }
  }
  rep(i, n){
    if(chk[i] == INF){
      printf("No\n");
      return 0;
    }
  }
  printf("Yes\n");
  rep2(i, 1, n){
    printf("%d\n", chk[i] + 1);
  }
  return 0;
}