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

long *tree[100001];

int main(void) {

  long n,m;
  scanf("%ld %ld", &n, &m);

	long tree_s[n+1];
	for (long i = 1; i <= n; i++) {
		tree_s[i] = 0;
	}
  long a,b;
  for (long i = 0; i < m; i++) {
    scanf("%ld %ld", &a, &b);
    tree[a] = realloc(tree[a], sizeof(long)*(tree_s[a]+1));
    tree[a][tree_s[a]] = b;
		tree_s[a]++;
		tree[b] = realloc(tree[b], sizeof(long)*(tree_s[b]+1));
    tree[b][tree_s[b]] = a;
		tree_s[b]++;
  }

  long vertices[n+1];
  for (long i = 1; i <= n; i++) {
    vertices[i] = -1;
  }
	vertices[1] = 0;

	long visited[n+1];
	visited[0] = 1;
	long head = 0;
	long tail = 0;
	long tmp_tail = 0;

  long cur;
	int flag;
  while (1) {
		flag = 0;
    for (long i = head; i <= tail; i++) {
			cur = visited[i];
    	for (long j = 0; j <= tree_s[cur]-1; 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 (long i = 2; i <= n; i++) {
  	printf("%ld\n", vertices[i]);
  }

  return 0;
}