#include <algorithm>
#include <cctype>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <vector>

#ifdef GONGKUNPENG
#include <cassert>
#define _GG 1
#else
#define _GG 0
#endif

#define uint unsigned
#define ll long long
#define ull unsigned long long
#define vector std::vector
#define ms(a, v) memset(a, v, sizeof(a))
#define ufor(i, n) for (int i = 1; i < n; ++i)
#define sfor(i, n) for (int i = 1; i <= n; ++i)
#define tfor(i, n) for (int i = 0; i < n; ++i)
using std::max;
using std::min;
using std::sort;
using std::swap;

#define _GIO 1

#if _GIO
struct _gio {
#define BFSZ 1 << 18
#define blank(x) (x == ' ' || x == '\t' || x == '\n' || x == '\r')

  char rcha;
  bool rneg;
#if _GG
#else
  char ruf[BFSZ], wuf[BFSZ], *r1, *r2, *w1;
#endif

  _gio() {
    rcha = ' ';
#if _GG
#else
    r1 = r2 = ruf, w1 = wuf;
#endif
  }

  ~_gio() {
#if _GG
#else
    fwrite(wuf, 1, w1 - wuf, stdout);
#endif
  }

  inline void flush() {
#ifdef _GG
#else
    fwrite(wuf, 1, w1 - wuf, stdout), w1 = wuf;
#endif
  }

  inline int readc() {
#if _GG
    return getchar();
#else
    return (r1 == r2 && (r2 = (r1 = ruf) + fread(ruf, 1, BFSZ, stdin), r1 == r2)
                ? -1
                : *r1++);
#endif
  }

  template <typename T, typename... Args>
  void read(T &x, Args &... args) {
    read(x), read(args...);
  }

  inline void read() {}

  inline void read(char *s) {
    while (blank(rcha)) rcha = readc();
    while (!blank(rcha) && rcha > 0) *s++ = rcha, rcha = readc();
    *s = '\0';
  }

  inline void readl(char *s) {
    while (blank(rcha)) rcha = readc();
    while (rcha != '\n' && rcha > 0) *s++ = rcha, rcha = readc();
    *s = '\0';
  }

  template <typename T>
  inline void read(T &x) {
    x = rcha = rneg = 0;
    while (!isdigit(rcha) && rcha != '-') rcha = readc();
    rcha == '-' && (rneg = true, rcha = readc());
    while (isdigit(rcha)) x = (x << 3) + (x << 1) - 48 + rcha, rcha = readc();
    rneg && (x = -x);
  }

  inline void writec(char c) {
#if _GG
    putchar(c);
#else
    (w1 - wuf == BFSZ) && (fwrite(wuf, 1, BFSZ, stdout), w1 = wuf);
    *w1++ = c;
#endif
  }

  template <typename T, typename... Args>
  void write(const T &x, const Args &... args) {
    write(x), write(args...);
  }

  template <typename T, typename... Args>
  void writel(const T &x, const Args &... args) {
    write(x), write(args...);
    writec('\n');
  }

  inline void write() {}

  inline void write(const char &c) { writec(c); }

  template <typename T>
  void write(T x) {
    if (x < 0) {
      writec('-');
      write(-(long long)(x));
      return;
    }
    if (x > 9) write(x / 10);
    writec(x % 10 ^ 48);
  }

  inline void write(const char *s) {
    while (*s) writec(*s++);
  }
#undef BFSZ
} io;
#endif

const int INF = 0x3f3f3f3f;
const int MAXN =
#ifdef GONGKUNPENG
    15
#else
    200005
#endif
    ;

vector<int> ps[MAXN];
bool vis[MAXN];
int nxt[MAXN];
int trc[MAXN];
int que[MAXN << 2];

int main() {
  int n, m, a, b, fnt, bck;
  io.read(n, m);
  tfor(i, m) {
    io.read(a, b);
    ps[a].push_back(b);
    ps[b].push_back(a);
  }
  b = fnt = bck = 0;
  que[fnt++] = 0;
  que[fnt++] = 1;
  vis[1] = true;
  while (fnt > bck) {
    b = que[bck++];
    a = que[bck++];
    trc[b] = a;
    nxt[a] = trc[b - 1];
    for (const auto &i : ps[a]) {
      if (!vis[i]) {
        vis[i] = true;
        que[fnt++] = b + 1;
        que[fnt++] = i;
      }
    }
  }
  sfor(i, n) if (!vis[i]) {
    io.write("No\n");
    return 0;
  }
  io.write("Yes\n");
  for (int i = 2; i <= n; ++i) io.writel(nxt[i]);
  return 0;
}

Measured memory_bytes: 13500