#include <bits/stdc++.h>
/*#include <ext/pb_ds/assoc_container.hpp> // Common file

using namespace __gnu_pbds;   //policy-based data structures (like set with adttional functionality) some operations 
//(*name.find_by_order(x) it givesyou value of x index in sorted set and name.find_by_key(no) it gives you the number at index no before sorting)

 typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update> pbds_s;




/* OHH..... BHAI MAARO... MUJHE MAARO.... JO MEIN ISS.. MAADHERCHOD CONTEST MEIN AAYA...*/






using namespace std;

#define ull                   unsigned long long	
#define ld                    long double
#define PI                    3.14159265358979323846264338327950L
#define substring             s.substr(form_index,to_which_index) //last index is not included
#define fastio                ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define ll                    long long int
#define deque                 deque<int> d; //dynamic array with push_front() ans pop_front functionality
#define PQ                    priority_queue<int> p; //max_heap stored data in decresing order
#define RPQ                   priority_queue<int,vector<int>,greater<int>> p; //min_heap in increasing order
#define decimalupto(no,y)     fixed<<setprecision(y)<<no
#define b_to_d(no)            bitset<32> ans("no");ans.to_ullong(); //when you have to make an array of binary array
#define d_to_b(no,upto)       bitset<upto> ans(no);ans.to_string(); //then you use bitset<int> name.And you can use operations (a&b),(a|b),(a^b)
#define inf                   1e9+5
#define mod                   1e9+7//1e9+7
#define count1(no)            __builtin_popcountll(no) //tells us the number of setbits means the total no. of 1 in a binary no.
#define count0_front(no)      __builtin_clz(no)// tells us the number of 0s in a binary no. from begiining
#define count0_back(no)       __builtin_ctz(no) //tells us the number of 0s from the count0_back
#define parity(no)            __builtin_parity(no)// tells the number is even or odd by counting the number of 1s 
#define Erase(i)              myvector.erase (myvector.begin()+i);//erase a specific element from a vector
#define grp_Erase(i)          myvector.erase (myvector.begin(),myvector.begin()+i); //erase the first i elemnts from a vector
#define copy array            copy(arr1.begin(), arr1.begin()+n, arr2.begin());
#define to_uppercase(s)       transform(s.begin(), s.end(), s.begin(), ::toupper);
#define to_lowercase(s)       transform(s.begin(), s.end(), s.begin(), ::tolower); 
#define gcd(a,b)              __gcd(a,b)
#define array_to_string       to_string(i) or string.push_back(arr[i]+'0')
#define string_to_int         s[i]-'a'
ll power(ll x,ll y,ll md=mod){
	ll res = 1;
	x%=md;
	while(y>0){
		if(y&1)res = (res*x)%md;
		x *= x;
		 if(x>=md) x %= md; y >>= 1;
		}
		return res;
	}

//#define left_operand(x<<y)    is equivalent to (x*2^y)
//#define right_operand(x>>y)   is equivalent to (x/2^y)

//int arr[100][100];
const int mx=1e5+5;
bool visited[mx];
queue<int> q;
vector<int> adj[mx];
int ans[mx];

int main(){	
	
	   fastio // WHEN TAKE MOD THEN TAKE WITH (ll)mod  
	   memset(visited,sizeof(visited),false);
	   int n,m;
	   cin>>n>>m;
	   bool flag=0;
	   for(int i=0; i<m; ++i){
	   	int x,y;
	   	cin>>x>>y;
	   	adj[x].push_back(y);
	   	adj[y].push_back(x);
	   	if(x==1 || y==1) flag=1;
	   }
	   if(!flag){
	   	cout<<"No\n";
	   	return 0;
	   }
	   q.push(1);
	   while(!q.empty()){
	   	int x = q.front();
	   	q.pop();
	   	if(!visited[x]){
	   		visited[x]=1;
	   		for(int i=0; i<adj[x].size(); ++i){
	   			q.push(adj[x][i]);
	   			if(ans[adj[x][i]]==0){
	   				ans[adj[x][i]]=x;
	   			}
	   		}
	  	}
	}
	cout<<"Yes\n";
	for(int i=2; i<=n; ++i)
		cout<<ans[i]<<"\n";
}

 


	
	   
       



Measured memory_bytes: 11220