def dfs(v, level):
    global visited, levels
    visited.append(v)
    levels[v] = level
    
    for u in g[v]:
        #print('level=',levels[v]+1)
        visited = visited[:levels[v]]
        
        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, levels[v]+1)


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

g = defaultdict(list)

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

#print(g)  

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

print('NO')