def dfs(v, level):
    global visited, levels, deep
    deep+=1
    if deep > 20000:
        print('NO')

    visited.append(v)
    #levels[v] = level
    
    for u in g[v]:
        #print('level=',levels[v]+1)
        if len(visited) > level:
            visited = visited[:level]
        
        if u==1 and len(visited) == n-1:
            print('YES')
            print(1, *visited, 1)
            sys.exit()  
        if u not in visited:
            #print('v, u=',v, u)
            #print(*visited)
            dfs(u, level+1)


from collections import defaultdict
import sys
sys.setrecursionlimit(50000)
n, m = map(int, input().split())

if n > 20000:
    print('NO')
    exit()

g = defaultdict(list)

for i in range(m):
    v,u= map(int, sys.stdin.readline().split())
    g[v].append(u)

#print(g)  

for start in g[1]:
    visited = []
    levels = defaultdict(int)
    deep=0
    dfs(start, 1)   

print('NO')