#include <stdio.h>
#include <stdbool.h>

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

  int nPoint = n;

  int sp = 0;
  printf("Yes\n");

  int sRoute[nPoint]; 
  int sDist;          

  int pDist[nPoint]; 
  int pRoute[nPoint];
  bool pFixed[nPoint]; 
  int sPoint, i, j, newDist;

  sDist = 999999; 

  for (i = 0; i < nPoint; i++)
  {
    sRoute[i] = -1;    
    pDist[i] = 999999; 
    pFixed[i] = false; 
  }

  pDist[sp] = 0; 

  while (true)
  { //dijk
    i = 0;
    while (i < nPoint)
    { 
      if (pFixed[i] == 0)
      {
        break; 
      }
      i = i + 1;
    }

    if (i == nPoint)
    {        
      break; 
    }

    for (j = i + 1; j < nPoint; j++)
    {
      if ((pFixed[j] == 0) && (pDist[j] < pDist[i]))
      {
        i = j;
      }
    }

    sPoint = i;
    pFixed[sPoint] = true;

    for (j = 0; j < nPoint; j++)
    {
      if ((Distance[sPoint][j] > 0) && (pFixed[j] == 0))
      {
        newDist = pDist[sPoint] + Distance[sPoint][j];
        if (newDist < pDist[j])
        {
          pDist[j] = newDist;
          pRoute[j] = sPoint;
        }
      }
    }
  }

  for(int dp=1;dp<n;dp++){
    sDist = pDist[dp];
    j = 0;
    i = dp;
    while (i != sp){
      sRoute[j] = i;
      i = pRoute[i];
      j = j + 1;
    }
    sRoute[j] = sp;
    printf("%d\n", sRoute[1] + 1);
  }
  return 0;
}