#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, m;
  cin >> n >> m;
  vector<vector<int>> v(n, vector<int>(n, 0));
  int x, y;
  for (int i = 0; i < m; i++) {
    cin >> x >> y;
    v[x - 1][y - 1] = 1;
    v[y - 1][x - 1] = 1;
  }
  vector<bool> visited(n, 0);
  int parent[n];
  parent[0] = -1;
  queue<int> q;
  visited[0] = 1;
  q.push(0);
  while (!q.empty()) {
    int x = q.front();
    q.pop();
    for (int i = 0; i < n; i++) {
      if (v[x][i] && visited[i] == 0) {
        visited[i] = 1;
        parent[i] = x;
        q.push(i);
      }
    }
  }
  for (int i = 0; i < n; i++) {
    if (visited[i] == 0) {
      cout << "No\n";
      return 0;
    }
  }
  cout << "Yes\n";
  for (int i = 1; i < n; i++) cout << parent[i] + 1 << "\n";
  return 0;
}
