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

int main(void) {

  int n,m;
  scanf("%d %d", &n, &m);
  int **tree;
  tree = (int **)malloc(sizeof (int*) * (n+1));
  for (int i = 0; i < n+1; i++) {
    tree[i] = (int *)malloc(sizeof (int) * (n+1));
    tree[i][0] = 0;
  }
  for (int i = 1; i <= n; i++) {
    tree[0][i] = 0;
  }
  int a,b;
  for (int i = 0; i < m; i++) {
    scanf("%d %d", &a, &b);
    tree[a][0]++;
    tree[a][tree[a][0]] = b;
    tree[b][0]++;
    tree[b][tree[b][0]] = a;
  }
  int vertices[n+1];
  for (int i = 1; i <= n; i++) {
    vertices[i] = -1;
  }
	vertices[1] = 0;

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

	printf("Yes\n");

  for (int i = 2; i <= n; i++) {
  	if (vertices[i] == -1) {
  		printf("1\n");
  	} else {
			printf("%d\n", vertices[i]);
		}
  }
	free(tree);

  return 0;
}