#include <bits/stdc++.h>
int main() {
  int n, m;
  scanf("%d%d", &n, &m);
  int a[m + 1], b[m + 1], len[n + 1], root[n + 1];
  for (int i = 1; i <= m; i++) {
    scanf("%d%d", &a[i], &b[i]);
  }
  for (int i = 1; i <= n; i++) {
    len[i] = m;
  }
  len[1] = 0;
  for (int i = 1; i <= m; i++) {
    if (a[i] == 1 || b[i] == 1) {
      int s = a[i], t = b[i];
      a[i] = a[1];
      b[i] = b[1];
      a[1] = s;
      b[1] = t;
      break;
    }
  }
  for (int k = 1; k <= 10; k++) {
    for (int i = 1; i <= m; i++) {
      if (len[a[i]] > len[b[i]]) {
        len[a[i]] = len[b[i]] + 1;
        root[a[i]] = b[i];
      }
      if (len[a[i]] < len[b[i]]) {
        len[b[i]] = len[a[i]] + 1;
        root[b[i]] = a[i];
      }
    }
    for (int i = m; i <= 1; i--) {
      if (len[a[i]] > len[b[i]]) {
        len[a[i]] = len[b[i]] + 1;
        root[a[i]] = b[i];
      }
      if (len[a[i]] < len[b[i]]) {
        len[b[i]] = len[a[i]] + 1;
        root[b[i]] = a[i];
      }
    }
    for (int i = 1; i <= m; i++) {
      if (len[a[i]] > len[b[i]]) {
        len[a[i]] = len[b[i]] + 1;
        root[a[i]] = b[i];
      }
      if (len[a[i]] < len[b[i]]) {
        len[b[i]] = len[a[i]] + 1;
        root[b[i]] = a[i];
      }
    }
    for (int i = m; i <= 1; i--) {
      if (len[a[i]] > len[b[i]]) {
        len[a[i]] = len[b[i]] + 1;
        root[a[i]] = b[i];
      }
      if (len[a[i]] < len[b[i]]) {
        len[b[i]] = len[a[i]] + 1;
        root[b[i]] = a[i];
      }
    }
    for (int i = 1; i <= m; i++) {
      if (len[a[i]] > len[b[i]]) {
        len[a[i]] = len[b[i]] + 1;
        root[a[i]] = b[i];
      }
      if (len[a[i]] < len[b[i]]) {
        len[b[i]] = len[a[i]] + 1;
        root[b[i]] = a[i];
      }
    }
    for (int i = m; i <= 1; i--) {
      if (len[a[i]] > len[b[i]]) {
        len[a[i]] = len[b[i]] + 1;
        root[a[i]] = b[i];
      }
      if (len[a[i]] < len[b[i]]) {
        len[b[i]] = len[a[i]] + 1;
        root[b[i]] = a[i];
      }
    }
    for (int i = 1; i <= m; i++) {
      if (len[a[i]] > len[b[i]]) {
        len[a[i]] = len[b[i]] + 1;
        root[a[i]] = b[i];
      }
      if (len[a[i]] < len[b[i]]) {
        len[b[i]] = len[a[i]] + 1;
        root[b[i]] = a[i];
      }
    }
    for (int i = m; i <= 1; i--) {
      if (len[a[i]] > len[b[i]]) {
        len[a[i]] = len[b[i]] + 1;
        root[a[i]] = b[i];
      }
      if (len[a[i]] < len[b[i]]) {
        len[b[i]] = len[a[i]] + 1;
        root[b[i]] = a[i];
      }
    }
    for (int i = 1; i <= m; i++) {
      if (len[a[i]] > len[b[i]]) {
        len[a[i]] = len[b[i]] + 1;
        root[a[i]] = b[i];
      }
      if (len[a[i]] < len[b[i]]) {
        len[b[i]] = len[a[i]] + 1;
        root[b[i]] = a[i];
      }
    }
    for (int i = m; i <= 1; i--) {
      if (len[a[i]] > len[b[i]]) {
        len[a[i]] = len[b[i]] + 1;
        root[a[i]] = b[i];
      }
      if (len[a[i]] < len[b[i]]) {
        len[b[i]] = len[a[i]] + 1;
        root[b[i]] = a[i];
      }
    }
    for (int i = 1; i <= m; i++) {
      if (len[a[i]] > len[b[i]]) {
        len[a[i]] = len[b[i]] + 1;
        root[a[i]] = b[i];
      }
      if (len[a[i]] < len[b[i]]) {
        len[b[i]] = len[a[i]] + 1;
        root[b[i]] = a[i];
      }
    }
    for (int i = m; i <= 1; i--) {
      if (len[a[i]] > len[b[i]]) {
        len[a[i]] = len[b[i]] + 1;
        root[a[i]] = b[i];
      }
      if (len[a[i]] < len[b[i]]) {
        len[b[i]] = len[a[i]] + 1;
        root[b[i]] = a[i];
      }
    }
    for (int i = 1; i <= m; i++) {
      if (len[a[i]] > len[b[i]]) {
        len[a[i]] = len[b[i]] + 1;
        root[a[i]] = b[i];
      }
      if (len[a[i]] < len[b[i]]) {
        len[b[i]] = len[a[i]] + 1;
        root[b[i]] = a[i];
      }
    }
    for (int i = m; i <= 1; i--) {
      if (len[a[i]] > len[b[i]]) {
        len[a[i]] = len[b[i]] + 1;
        root[a[i]] = b[i];
      }
      if (len[a[i]] < len[b[i]]) {
        len[b[i]] = len[a[i]] + 1;
        root[b[i]] = a[i];
      }
    }
    for (int i = 1; i <= m; i++) {
      if (len[a[i]] > len[b[i]]) {
        len[a[i]] = len[b[i]] + 1;
        root[a[i]] = b[i];
      }
      if (len[a[i]] < len[b[i]]) {
        len[b[i]] = len[a[i]] + 1;
        root[b[i]] = a[i];
      }
    }
    for (int i = m; i <= 1; i--) {
      if (len[a[i]] > len[b[i]]) {
        len[a[i]] = len[b[i]] + 1;
        root[a[i]] = b[i];
      }
      if (len[a[i]] < len[b[i]]) {
        len[b[i]] = len[a[i]] + 1;
        root[b[i]] = a[i];
      }
    }
  }
  printf("Yes\n");
  for (int i = 2; i <= n; i++) {
    printf("%d\n", root[i]);
  }
  return 0;
}
