#include <bits/stdc++.h>
using namespace std;
int INF = (1 << 30);
vector<vector<int> > grid;
vector<int> dis;
vector<int> signpost;
int calCulateMove(int source) {
  dis[source] = 0;
  queue<int> Q;
  Q.push(source);
  while (!Q.empty()) {
    int u = Q.front();
    Q.pop();
    for (int i = 0; i < grid[u].size(); i++) {
      int v = grid[u][i];
      if (dis[u] + 1 < dis[v]) {
        dis[v] = dis[u] + 1;
        signpost[v] = u;
        Q.push(v);
      }
    }
  }
  return 0;
}
int main() {
  int N, M;
  cin >> N >> M;
  grid = vector<vector<int> >(N + 1);
  dis = vector<int>(N + 1, INF);
  signpost = vector<int>(N + 1, -1);
  int a, b;
  for (int i = 0; i < M; i++) {
    cin >> a >> b;
    grid[a].push_back(b);
    grid[b].push_back(a);
  }
  calCulateMove(1);
  bool allTraversed = true;
  for (int i = 1; i <= N; i++) {
    if (dis[i] == INF) {
      allTraversed = false;
      break;
    }
  }
  if (allTraversed) {
    cout << "Yes\n";
    for (int i = 2; i <= N; i++) {
      cout << signpost[i] << endl;
    }
  } else {
    cout << "No\n";
  }
  return 0;
}
