#include <bits/stdc++.h>
using namespace std;
int n, m, d[10005], tot;
vector<int> a[10005];
void bfs();
queue<int> q;
int main() {
  cin >> n >> m;
  for (int i = 1; i <= m; ++i) {
    int x, y;
    scanf("%d%d", &x, &y);
    a[x].push_back(y);
    a[y].push_back(x);
  }
  bfs();
  return 0;
}
void bfs() {
  d[1] = 1;
  q.push(1);
  while (!q.empty() && tot < n) {
    int tmp = q.front();
    q.pop();
    ++tot;
    for (int i = 0; i < (int)a[tmp].size(); ++i) {
      if (d[a[tmp][i]] != 0) continue;
      d[a[tmp][i]] = tmp;
      q.push(a[tmp][i]);
    }
  }
  if (tot == n) {
    cout << "Yes\n";
    for (int i = 2; i <= n; ++i) printf("%d\n", d[i]);
    return;
  } else
    cout << "No";
}
