#include <bits/stdc++.h>
using namespace std;
long long ans[200000];
bool visited[200000];
long long dist[200000];
void dfs(vector<vector<long long> > edges, long long curr) {
  visited[curr] = true;
  for (long long i = 0; i < edges[curr].size(); i += 1) {
    if (dist[edges[curr][i]] == -1) {
      dist[edges[curr][i]] = 1 + dist[curr];
      ans[edges[curr][i]] = curr;
    } else if (dist[curr] + 1 < dist[edges[curr][i]]) {
      ans[edges[curr][i]] = curr;
      dist[edges[curr][i]] = 1 + dist[curr];
    }
  }
  for (long long i = 0; i < edges[curr].size(); i += 1) {
    if (!visited[edges[curr][i]]) dfs(edges, edges[curr][i]);
  }
  return;
}
int32_t main(void) {
  ios_base::sync_with_stdio(0);
  cin.tie(NULL);
  cout.tie(NULL);
  ;
  long long n, m;
  cin >> n >> m;
  ;
  vector<vector<long long> > edges(n + 1);
  for (long long i = 0; i < m; i += 1) {
    long long x, y;
    cin >> x >> y;
    ;
    edges[x].push_back(y);
    edges[y].push_back(x);
  }
  for (long long i = 1; i < n + 1; i += 1) {
    dist[i] = -1;
    visited[i] = false;
  }
  dist[1] = 0;
  dfs(edges, 1);
  bool res = true;
  for (long long i = 1; i < n + 1; i += 1) {
    if (!visited[i]) {
      res = false;
      break;
    }
  }
  if (!res)
    cout << "No" << endl;
  else {
    cout << "Yes" << endl;
    for (long long i = 2; i < n + 1; i += 1) cout << ans[i] << endl;
  }
}
