def dfs(v):
    global visited, start
    visited.append(v)
    for u in g[v]:
        if v==start and len(visited) == n:
            print('YES')
            print(*visited)
            return True  
        elif v == start:
            visited = [start]    
        if u not in visited:
            #print('v, u=',v, u)
            dfs(u)
    return False


from collections import defaultdict
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 = []
    r = dfs(start)
    #print('-----')
if not r: 
    print('NO')   
      
