#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const ll MOD = 1000000007;
const ll MOD2 = 998244353;
const double PI = 3.14159265358979;
const ll INF = pow(10, 18);
string abc = "abcdefghijklmnopqrstuvwxyz";
string ABC = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
struct edge {
  ll to, cost;
};
const ll MAX_N = 100000;
vector<ll> G[MAX_N];
vector<ll> cost(MAX_N, INF);
vector<ll> X(MAX_N);
void bfs(ll x, ll y) {
  ll k = G[x].size();
  cost[x] = y;
  for (ll i = 0; i < k; i++) {
    if (cost[G[x][i]] > y + 1) {
      X[G[x][i]] = x;
      bfs(G[x][i], y + 1);
    }
  }
}
int main() {
  ll n, m;
  cin >> n >> m;
  vector<ll> a(m), b(m);
  cout << "Yes" << endl;
  for (ll i = 0; i < m; i++) {
    cin >> a[i] >> b[i];
    a[i]--;
    b[i]--;
    G[a[i]].push_back(b[i]);
    G[b[i]].push_back(a[i]);
  }
  bfs(0, 0);
  for (ll i = 1; i < n; i++) {
    cout << X[i] + 1 << endl;
  }
}
