#include <bits/stdc++.h>
using namespace std;

typedef long long int ll;
typedef pair<int, int> pii;
bool R(){return true;}
template<typename T, typename ... Args>
bool R(T & x, Args & ... args){return cin >> x && R(args...);}
void init_io(){ios::sync_with_stdio(false);cin.tie(0);}

#define PB push_back
#define MP make_pair
#define FOR(prom, a, b) for(int prom = (a); prom < (b); prom++)
#define FORDE(prom, a, b) for(int prom = (a); prom >= (b); prom--)
#define SV(vec) do{int __sv;R(__sv);vec.PB(__sv);}while(0)
#define ALL(vec) (vec).begin(), (vec).end()
#define MM(co, cim) memset((co), (cim), sizeof((co)))
#define DEB(x) cerr << ">>> " << #x << " : " << x << endl;
#define INF   1000000007
#define INFLL 4000000000000000007LL

//-------------------------------------------------------------------------//
/*******************************
 * SINGLE SOURCE SHORTEST PATH *
 *******************************
 Postup: 1) Vytvorit instanci SSSP<typ vah grafu>(#vrcholu grafu, infinity value pro vzdalenosti)
         2) Pridat hrany do grafu
         ...
         2) Pouzit - zapise do predaneho pole vzdalenosti 
                   - Bellman Ford vrati false, pokud existuje zaporny cyklus
 */
//-------------------------------------------------------------------------//

namespace sssp
{
  template <typename weight_val>
  struct Edge
  {
    int        from;
    int        to;
    weight_val weight;
    
    Edge (int from, int to, const weight_val & weight)
         : from(from), to(to), weight(weight)
    {
    }
  };
  
  template <typename weight_val>
  struct SSSP
  {
    vector<vector<int>>      graph;
    vector<Edge<weight_val>> edges;
    weight_val               INFINITY_VAL;
    
    SSSP (int N, const weight_val & INFINITY_VAL)
         : INFINITY_VAL(INFINITY_VAL)
    {
      graph.resize(N);
    }
    
    void add_edge (int from, int to, const weight_val & weight)
    {
      edges.PB(Edge<weight_val>(from, to, weight));
      int eid = edges.size() - 1;
      graph[from].PB(eid);
      graph[to].PB(eid);
    }
    
    void dijkstra (int source, int * dist, int * prev = 0)
    {
      int n = graph.size();
      int m = edges.size();
      priority_queue<pair<weight_val, int>> pq;
      vector<bool> used; 
      
      FOR(i, 0, n) 
      {
        dist[i] = INFINITY_VAL;
        if (prev) prev[i] = -1;
      }
      used.resize(n, false);
      dist[source] = 0;
      pq.push(MP(0, source));
      
      while (!pq.empty())
      {
        auto pqpair = pq.top();pq.pop();
        int x = pqpair.second;
        if (used[x]) continue;
        used[x] = true;
        FOR(i, 0, graph[x].size())
        {
          int y = x ^ edges[graph[x][i]].from ^ edges[graph[x][i]].to;
          weight_val edge_dist = edges[graph[x][i]].weight;
          if (dist[x] + edge_dist < dist[y])
          {
            dist[y] = dist[x] + edge_dist;
            pq.push(MP(-dist[y], y));
            if (prev) prev[y] = x;
          }
        }
      }
    }
    
    bool bellman_ford (int source, int * dist, int * prev = 0)
    {
      int n = graph.size();
      int m = edges.size();
      
      FOR(i, 0, n) 
      {
        dist[i] = INFINITY_VAL;
        if (prev) prev[i] = -1;
      }
      dist[source] = 0;
      
      FOR(phase, 0, n - 1)
      {
        FOR(i, 0, m)
        {
          if (dist[edges[i].from] + edges[i].weight < dist[edges[i].to])
          {
            dist[edges[i].to] = dist[edges[i].from] + edges[i].weight;
            if (prev) prev[edges[i].to] = edges[i].from;
          }
        }
      }
      
      bool is_wo_cycle = true;
      FOR(i, 0, m) if (dist[edges[i].from] + edges[i].weight < dist[edges[i].to]) 
      {
        is_wo_cycle = false;
        break;
      }
      
      return is_wo_cycle;
    }
    
  };
}

using namespace sssp;
//-------------------------------------------------------------------------//

int n, m, d[100014], p[100014];
SSSP<int> g = SSSP<int>(100014, INF);

void solve ()
{
  R(n, m);
  FOR(i, 0, m)
  {
    int from, to;
    R(from, to);--from;--to;
    g.add_edge(from, to, 1);
  }
  g.dijkstra(0, d, p);
  int gv = 0;
  FOR(i, 1, n) if (d[i] != INF) ++gv;
  if (gv < n - 1) printf("No\n");
  else
  {
    printf("Yes\n");
    FOR(i, 1, n) printf("%d\n", p[i] + 1);
  }
}

int main ()
{
  init_io();
  int t = 1;
  //R(t);
  while (t--) solve();
  return 0;
}


Measured memory_bytes: 14364