/*
URL_HERE
*/
/*

*/
#ifdef _WIN32
	#pragma warning(disable:4996)
#endif
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <algorithm>
#include <math.h>
#define PI 3.141592653589793238462643383279502884197169399375105820974
#define ten5p1 100001
#define ten6p1 1000001
#define ten8p1 100000001
#define ten9p1 1000000001
#define ll long long
#define rep(var,n) for(int var=0;var<n;++var)
#define repi(n) rep(i,n)
#define repj(n) rep(j,n)
#define repi1(n) for(int i=1;i<n;++i)
#define _min(a,b) a<b?a:b
#define _max(a,b) a>b?a:b
#define zeroi(data,n) memset(data,0,sizeof(int)*n);
#define zeroll(data,n) memset(data,0,sizeof(long long)*n);
#define one(data,n) {for(int _ONEI=0;_ONEI<n;++_ONEI) data[_ONEI]=1;}
#define readc(var) fscanf(_fin,"%c",var)
#define readi(var) fscanf(_fin,"%d",var)
#define readll(var) fscanf(_fin,"%lld",var)
#define repreadi(data,n) rep(_repreadi, n) readi(&data[_repreadi])
#define writec(var) fprintf(_fout,"%c",var)
#define writecsp(var) fprintf(_fout,"%c ",var)
#define writecln(var) fprintf(_fout,"%c\n",var)
#define writei(var) fprintf(_fout,"%d",var)
#define writeisp(var) fprintf(_fout,"%d ",var)
#define writellsp(var) fprintf(_fout,"%lld ",var)
#define writeiln(var) fprintf(_fout,"%d\n",var)
#define writellln(var) fprintf(_fout,"%lld\n",var)
#define writefln(var) fprintf(_fout,"%f\n",var)
#define writes(str) fprintf(_fout,"%s",str)
#define writesp() fprintf(_fout," ")
#define writeln() fprintf(_fout,"\n")
#define iseven(x) ((x&1)==0 ? 1:0)
#define RUN_LOCAL(testfilename) {_fin = fopen(testfilename, "r"); if(_fin==NULL) _fin=stdin;}
#define swap(type,a, b) {type t=a;a=b;b=t;}
#define swapxor(a,b) {a^=b;b^=a;a^=b;}
#define sort(data,n) std::sort(data,data+n)
#define mod(a,b) b==0 ? 0 : a==0 ? 0 :(a>0 ? a%b : b + a % b)
ll gcd(ll a, ll b) { if (b == 0) return a; return gcd(b, a % b); }

FILE* _fin = stdin;
FILE* _fout = stdout;
void reversei(int* data, int n) { int k = n >> 1; repi(k) { int tmp = data[i]; data[i] = data[n - i - 1]; data[n - i - 1] = tmp; } }
int bsearch(int val, int* data, int n) { if (data[0] > val) return -1; if (data[n - 1] < val) return n; int l = 0; int r = n - 1; for (; l < r;) { int mid = (l + r + 1) >> 1; if (data[mid] <= val) l = mid; else r = mid - 1; }if (data[r] != val) ++r; return r; }
int reads(char* str, int maxsize) 
{ 
	for (;;)
	{ 
		if(fgets(str, maxsize, _fin)==NULL) break; 
		if (str[0] != '\n' && str[0] != '\r') break;
	} 
	int slen = strlen(str); 
	if (slen == 0) return 0;
	if (str[slen - 1] == '\n' || str[slen - 1] == '\r') str[--slen] = 0;
	return slen; 
}

#define _Vec(type, name) \
struct name { type* data; int size; int n; };\
void init(name* t, int size) { t->data = (type*)malloc(sizeof(type) * size); t->size = size; t->n = 0; }\
void resize(name* t) { int ns = t->size * 1.2f; t->data = (type*)realloc(t->data, sizeof(type) * ns); t->size = ns; }\
void add(name* t, type val) { if (t->n >= t->size) resize(t); int k = t->n; t->data[k] = val; t->n = k + 1; }\
void free(name* t) { free(t->data);}
_Vec(int, Veci)
_Vec(long long, Vecll)
_Vec(char*, Vecs)

#define _ispal(type, name) int name(type* a, type* b, int n){repi(n){if (a[i] != b[n - i - 1]){return 0;}}return 1;}
_ispal(int, ispali)
_ispal(char, ispalc)


#define _Pair(type, name) struct name{type x, y;}; \
int cmp_##name(const void* _a, const void* _b){name* a = (name*)_a;name* b = (name*)_b;if (a->x == b->x){if (a->y < b->y) return -1;else return 1;}if (a->x < b->x) return -1;else return 1;}\
void sort_##name(name* d, int n){qsort(d, n, sizeof(name), cmp_##name);}
	_Pair(int, Pairi)

	int cmp_Str(const void* _a, const void* _b) { char* a = *((char**)_a); char* b = *((char**)_b); return strcmp(a, b); }
void sort_Str(char** str, int n) { qsort(str, n, sizeof(char*), cmp_Str); }

void f(Veci **e,int* visiteidx, int nvisiteidx, int* dist)
{
	int currenteidx = 0;
	for (; currenteidx < nvisiteidx;)
	{
		int k = visiteidx[currenteidx];
		repi(e[k]->n)
		{
			int l = e[k]->data[i];
			if (dist[l] == -1)
			{
				dist[l] = dist[k] + 1;
				visiteidx[nvisiteidx++] = l;
			}		
		}
		++currenteidx;
	}
}

int main()
{
	RUN_LOCAL("dataabc168D.txt");

	int n,m; readi(&n); readi(&m);
	Veci** edge = (Veci**)malloc(sizeof(Veci*) * ten5p1);
	repi(n)
	{
		edge[i] = (Veci*)malloc(sizeof(Veci));
		init(edge[i], 10);
	}

	static int sign[ten5p1];
	static int dist[ten5p1];
	static int visitlist[ten5p1];
	int nvisitlist = 0;
	repi(ten5p1) {sign[i] = -1; dist[i] = -1;}
	
	repi(m)
	{
		int a, b; readi(&a); readi(&b);
		a--; b--;
		add(edge[a], b);
		add(edge[b], a);
	}

	sign[0] = 0;
	dist[0] = 0;
	visitlist[0] = 0;
	f(edge, visitlist, 1, dist);

	repi(n)
	{
		int best = ten5p1;
		int bestidx = -1;
		repj(edge[i]->n)
		{
			int k = edge[i]->data[j];
			if (dist[k] < best)
			{
				best = dist[k];
				bestidx = k;
			}
		}

		if (bestidx != -1) sign[i] = bestidx;
	}

	int fail = 0;
	repi(n)
	{
		if (sign[i] == -1)
		{
			fail = 1;
			break;
		}
	}

	if (fail)
	{
		writes("No\n");
	}
	else
	{
		writes("Yes\n");
		repi1(n)
		{	
			writeiln(sign[i] + 1);
		}
	}

	return 0;
}

Measured memory_bytes: 12148