#include<stdio.h>
int a[400005], b[400005];
int h[1000006], l;
int dist[200005];
int comp_h(int x, int y, int z)
{
	if (z == 0)
	{
		if (a[h[x]] > a[h[y]])
			return 1;
		return -1;
	}
	else
	{
		if (dist[h[x]] > dist[h[y]])
			return 1;
		return -1;
	}
}
void swap_h(int x, int y)
{
	int f = h[x];
	h[x] = h[y];
	h[y] = f;
	return;
}
void f1(int ne, int z)
{
	h[l] = ne;
	int p = l;
	l++;
	while (p > 0)
	{
		if (comp_h((p - 1) / 2, p, z) > 0)
			swap_h((p - 1) / 2, p);
		p = (p - 1) / 2;
	}
	return;
}
int f2(int z)
{
	l--;
	swap_h(0, l);
	int p = 0;
	for (;;)
	{
		if (2 * p + 2 < l)
		{
			if (comp_h(2 * p + 1, 2 * p + 2, z) > 0)
			{
				if (comp_h(p, 2 * p + 2, z) > 0)
					swap_h(p, 2 * p + 2);
				p = 2 * p + 2;
			}
			else
			{
				if (comp_h(p, 2 * p + 1, z) > 0)
					swap_h(p, 2 * p + 1);
				p = 2 * p + 1;
			}
		}
		else if (2 * p + 1 < l)
		{
			if (comp_h(p, 2 * p + 1, z) > 0)
				swap_h(p, 2 * p + 1);
			p = 2 * p + 1;
		}
		else
			break;
	}
	return h[l];
}
int main()
{
	int n, m;
	scanf("%d %d", &n, &m);
	int i;
	for (i = 0; i < m; i++)
	{
		i *= 2;
		scanf("%d %d", &a[i], &b[i]);
		a[i]--;
		b[i]--;
		a[i + 1] = b[i];
		b[i + 1] = a[i];
		i /= 2;
	}
	l = 0;
	for (i = 0; i < 2 * m; i++)
		f1(i, 0);
	int c[400005];
	for (i = 0; i < 2 * m; i++)
		c[i] = f2(0);
	int min, mid, max;
	for (i = 0; i < n; i++)
		dist[i] = 2 * n;
	int ans[200005];
	l = 0;
	dist[0] = 0;
	f1(0, 1);
	while (l > 0)
	{
		i = f2(1);
		min = -1;
		max = 2 * m;
		while (max - min > 1)
		{
			mid = (max + min) / 2;
			if (a[c[mid]] < i)
				min = mid;
			else
				max = mid;
		}
		if (max < 2 * m)
		{
			while (a[c[max]] == i)
			{
				if (dist[b[c[max]]] > dist[i] + 1)
				{
					ans[b[c[max]]] = i;
					dist[b[c[max]]] = dist[i] + 1;
					f1(b[c[max]], 1);
				}
				max++;
				if (max == 2 * m)
					break;
			}
		}
	}
	printf("Yes\n");
	for (i = 1; i < n; i++)
		printf("%d\n", ans[i] + 1);
	return 0;
}