#include<stdio.h>

int main(void)
{
	unsigned long int a, b, c, d;
	int i, j;
	unsigned long int M[2][200000];
	unsigned long int N[2][200000];
	unsigned long int tab;

	scanf("%ld%ld", &a, &b);

	N[1][0] = 0;
	N[0][0] = 1;

	for (i = 1; i < a; i++) {
		N[1][i] = 0;
		N[0][i] = 0;
	}

	for (i = 0; i < b; i++) {
		scanf("%ld%ld", &M[0][i], &M[1][i]);
	}

		for (i = 0; i < a; i++) {
			for (j = 0; j < b; j++) {
				if ((N[0][M[0][j] - 1] != 0) && (N[0][M[1][j] - 1] == 0)) {
					N[0][M[1][j] - 1] = 1;
					N[1][M[1][j] - 1] = M[0][j];
				}
				else if ((N[0][M[0][j] - 1] == 0) && (N[0][M[1][j] - 1] != 0)) {
					N[0][M[0][j] - 1] = 1;
					N[1][M[0][j] - 1] = M[1][j];
				}
			}
		}

	for (i = 0; i < a; i++) {
		if (N[0][i] == 0) {
			printf("No");
			return 0;
		}
	}

	printf("Yes\n");

	for (i = 1; i < a; i++) {
		printf("%lld\n", N[1][i]);
	}

	return 0;
}