// Slower C++ solution:
#include <bits/stdc++.h>

using namespace std;

typedef long long ll;

typedef unsigned long long ull;

 

#define pb push_back

#define mp make_pair

#define f0(i,b) for(int i=0;i<(b);i++)

#define f1(i,b) for(int i=1;i<=(b);i++)

#define f2(i,a,b) for(int i=(a);i<=(b);i++)

#define sf(a) scanf("%d",&a);

#define sfl(a) scanf("%lld",&a);

 

bool vis[200005];

vector<int> v[200001];

int l[200001],p[200001];

 

void edge(int a, int b)

{

    v[a].pb(b);

    v[b].pb(a);

}

void bfs(int u)

{

    queue<int> q;

    q.push(u);

    vis[u] = true;

    int x;

    while (!q.empty()) {

 

        int f = q.front();

        q.pop();

 

        for (int i = 0; i < v[f].size(); i++){

            x = v[f][i];

            if(!vis[x]){

                q.push(x);

                l[x] = l[f] + 1;

                p[x] = f;

                vis[x] = true;

            }

        }

    }

 

}

void init(){

  for(int i = 0 ; i <= 2000; i++)

  l[i] = 0;

 

  for(int i = 0 ; i <= 2000 ; i++)

     v[i].clear();

 

}

int main(){

    ios_base::sync_with_stdio(0); cin.tie(NULL); cout.tie(NULL);

    //freopen("input.txt", "r", stdin);

    //freopen("output.txt", "w", stdout);

     int node, edg, a, b;

     cin >> node >> edg;

     for(int i = 0 ; i < edg; i++){

         cin >> a >> b;

         edge(a,b);

     }

     l[1] = 1;

     bfs(1);

     int c = 0;

     for(int i = 1 ; i <= node ; i++){

       if(vis[i])

          c++;

     }

     if(c == node){

      cout << "Yes" << endl;

      for(int i = 2 ; i <= node ; i++) cout << p[i] << endl;

     }

     else cout << "No" << endl;

 

 

    return 0;

}

// Faster C++ solution for the same problem (measured speedup: 1.6375023556975146x):
///   ***   ---   |||		 In the name of ALLAH		|||   ---   ***   ///







#include<bits/stdc++.h>

using namespace std;





typedef long long ll;

typedef vector<int> vi;

typedef vector<ll> vl;

typedef vector<vi> vvi;

typedef vector<vl> vvl;

typedef pair<int,int> pii;

typedef pair<double, double> pdd;

typedef pair<ll, ll> pll;

typedef vector<pii> vii;

typedef vector<pll> vll;

typedef double dl;



#define endl '\n'

#define PB push_back

#define F first

#define S second

#define all(a) (a).begin(),(a).end()

#define rall(a) (a).rbegin(),(a).rend()

#define sz(x) (int)x.size()



const double PI = acos(-1);

const double eps = 1e-9;

const int inf = 2000000000;

const ll infLL = 9000000000000000000;

#define MOD 1000000007



#define mem(a,b) memset(a, b, sizeof(a) )

#define sqr(a) ((a) * (a))



#define optimize() ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);

#define fraction() cout.unsetf(ios::floatfield); cout.precision(10); cout.setf(ios::fixed,ios::floatfield);

#define file() freopen("input.txt","r",stdin);freopen("output.txt","w",stdout);



#define dbg(args...) do {cerr << #args << " : "; faltu(args); } while(0)

void faltu () {			cerr << endl;}

template < typename T, typename ... hello>void faltu( T arg, const hello &... rest) {cerr << arg << ' ';faltu(rest...);}



ll gcd ( ll a, ll b ) { return __gcd ( a, b ); }

ll lcm ( ll a, ll b ) { return a * ( b / gcd ( a, b ) ); }





int dx[] = { 0, 0, +1, -1, -1  +1, -1, +1 };

int dy[] = { +1, -1, 0, 0, -1, +1, +1, -1 };





const int mx = 1e5+123;

int lev[mx];

vi adj[mx];

int par[mx];



void bfs ( int s )

{

	mem ( lev, -1 );



	queue<int> q;

	q.push ( s );



	while ( !q.empty() ) {

		int u = q.front();

		q.pop();



		for ( auto v : adj[u] ) {

			if ( lev[v] == -1 ) {

				lev[v] = lev[u] + 1;

				par[v] = u;

				q.push( v );

			}

		}

	}

}





int main()

{

	optimize();



	int n, m;

	cin >> n >> m;

	for ( int i = 1; i <= m; i++ ) {

		int u, v;

		cin >> u >> v;

		adj[u].PB ( v );

		adj[v].PB ( u );

	}



	bfs ( 1 );



	for ( int i = 2; i <= n; i++ ) {

		if ( lev[i] == -1 ) return cout << "No", 0;

	}



	cout << "Yes\n";

	for ( int i = 2; i <= n; i++ ) cout << par[i] << endl;











	return 0;

}