#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0; i < (n); i++)
#define REP1(i, n) for(int i = 1; i <= (n); i++)
#define REPD(i,a,b) for (int i=(a);i<(b);i++)
#define ALL(v) (v).begin(), (v).end()
using namespace std;
typedef long long ll;
typedef vector<string> vs;
typedef vector<bool> vb;
typedef vector<vb> vvb;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef set<int> si;
typedef vector<si> vsi;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef pair<int, int> pi;
typedef queue<int> qi;
typedef queue<pi> qpi;
typedef pair<ll, ll> pll;
typedef queue<pll> qpll;
typedef vector<pi> vpi;
typedef vector<pll> vpll;
const int mod = 1000000007;
const int INF = 1001001001;
// 小数点　<< fixed << setprecision(0) <<
// sort降順　sort(ALL(),greater<int>());
// 円周率　M_PI
// 文字判定　isupper islower
// 文字変換　
// 順列　do {} while(next_permutation(ALL(X)));
// 最大値　LLONG_MAX
// a内でx以上　auto iter = lower_bound(ALL(a), x);
// a内でxより大きい　auto iter = upper_bound(ALL(a), x);
int dx[8] = {1, 0, -1, 0, 1, 1, -1, -1};
int dy[8] = {0, 1, 0, -1, 1, -1, 1, -1};
struct edge {
    int from; //出発点
    int to;   //到達点
    int cost; //移動コスト
};
typedef struct edge se;
typedef vector<edge> ve;
unsigned euclidean_gcd(unsigned a, unsigned b) {
  if(a < b) return euclidean_gcd(b, a);
  unsigned r;
  while ((r=a%b)) {
    a = b;
    b = r;
  }
  return b;
}
ll h,w;
ll ans=0;
int field[105][105]={0};
bool used[105][105];
int ex[6] = {-1,0,-1,1,-1,0};
int ey[6] = {-1,-1,0,0,1,1};
int ox[6] = {0,1,-1,1,1,0};
int oy[6] = {-1,-1,0,0,1,1};

int main() {
  int n,m;
  cin >> n >> m;
  vvi root(n);
  REP(i,m) {
    int a,b;
    cin >> a >> b;
    a--;
    b--;
    root[a].push_back(b);
    root[b].push_back(a);
  }
  vi mejirushi(n,-1);
  qi que;
  que.push(0);
  mejirushi[0]=0;
  int cnt=0;
  while(!que.empty()) {
    int now= que.front();
    que.pop();
    for(auto i:root[now]) {
      if(mejirushi[i]!=-1) continue;
      mejirushi[i]=now+1;
      que.push(i);
      cnt++;
    }
  }
  if(cnt==n-1) {
    cout << "Yes" << endl;
    REP1(i,n-1) {
      cout << mejirushi[i] << endl;
    } 
  } else {
    cout << "No" << endl;
  }
  return 0;
}
