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

int n;
int **country;
int srccyc(int c)
{
	if (country[0][c-1]) {
		puts("YES");
		putchar('1');
		return 1;
	} else {
		int i;
		for (i = 1; i < n; i++) {
			if (i == c-1)
				continue;
			if (country[i][c-1] && country[c-1][c-1] != 1)
				if (srccyc(i)) {
					putchar(' ');
					printf("%d", i+1);
					return 1;
				}
		}
	}
}

int main(void)
{
	int m;
	int i, j;
	int a, b;
	scanf("%d %d", &n, &m);
	country = malloc(n*sizeof(int*));
	for (i = 0; i < n; i++) {
		country[i] = malloc(n*sizeof(int));
		for (j = 0; j < n; j++)
			country[i][j] = 0;
	}

	while (m--) {
		scanf("%d %d", &a, &b);
		country[a-1][b-1] = 1;
	}

	if (!srccyc(1))
		puts("NO");
	else
		putchar('\n');

	for (i = 0; i < n; i++)
		free(country[i]);
	free(country);

	return 0;
}
