#include <stdio.h>
#include <stdlib.h>

typedef struct {
	long step;
	long connected;
} S_VERTICE;

int main(void) {

  long n,m;
  scanf("%ld %ld", &n, &m);
  long **tree;
  tree = (long **)malloc(sizeof (long*) * (n+1));
  for (long i = 0; i < n+1; i++) {
    tree[i] = (long *)malloc(sizeof (long) * (m+1));
    tree[i][0] = 0;
  }
  for (long i = 1; i <= n; i++) {
    tree[0][i] = 0;
  }
  long a,b;
  for (long i = 0; i < m; i++) {
    scanf("%ld %ld", &a, &b);
    tree[a][0]++;
    tree[a][tree[a][0]] = b;
    tree[b][0]++;
    tree[b][tree[b][0]] = a;
  }
  S_VERTICE vertices[n+1];
  for (long i = 1; i <= n; i++) {
		vertices[i].step = -1;
    vertices[i].connected = -1;
  }
	vertices[1].step = 1;
	vertices[1].connected = 0;

	long visited[n];
	visited[0] = 1;
	long head = 0;
	long tail = 0;
	long tmp_tail;
  long cur;
  while (1) {
		tmp_tail = tail;
    for (long i = head; i <= tail; i++) {
			cur = visited[i];
    	for (long j = 1; j <= tree[cur][0]; j++) {
				if (vertices[tree[cur][j]].connected != -1) {
					continue;
				}
    		vertices[tree[cur][j]].step = vertices[cur].step+1;
				vertices[tree[cur][j]].connected = cur;
				tmp_tail++;
				visited[tmp_tail] = tree[cur][j];
    	}
    }
		head = tail+1;
		tail = tmp_tail;
		if (tail == n-1) {
			break;
		}
  }
	free(tree);

	printf("Yes\n");

  for (long i = 2; i <= n; i++) {
    printf("%ld \n", vertices[i].connected);
  }

  return 0;
}
