






from __future__ import annotations






def    UpperCAmelCase__	(						lowerCamelCase  : Optional[int]						):
   global graph, reversed_graph, scc, component, visit, stack
   if visit[u]:
      return
   lowerCamelCase											=True
   for v in graph[u]:
      dfs(lowerCamelCase						)
   stack.append(lowerCamelCase						)






def    UpperCAmelCase__	(						lowerCamelCase  : Dict						):
   global graph, reversed_graph, scc, component, visit, stack
   if visit[u]:
      return
   lowerCamelCase											=True
   component.append(lowerCamelCase						)
   for v in reversed_graph[u]:
      dfsa(lowerCamelCase						)






def    UpperCAmelCase__	(						):
   global graph, reversed_graph, scc, component, visit, stack
   for i in range(lowerCamelCase						):
      dfs(lowerCamelCase						)
   lowerCamelCase											=[False] * n
   for i in stack[::-1]:
      if visit[i]:
         continue
      lowerCamelCase											=[]
      dfsa(lowerCamelCase						)
      scc.append(lowerCamelCase						)
   return scc


if __name__ == "__main__":
   # n - no of nodes, m - no of edges
   _UpperCAmelCase						,						_UpperCAmelCase				:	Any    						=    list(map(int, input().strip().split()))

   _UpperCAmelCase				:	list[list[int]]    						=    [[] for _ in range(n)]  # graph
   _UpperCAmelCase				:	list[list[int]]    						=    [[] for i in range(n)]  # reversed graph
   # input graph data (edges)
   for _ in range(m):
      _UpperCAmelCase						,						_UpperCAmelCase				:	Any    						=    list(map(int, input().strip().split()))
      graph[u].append(v)
      reversed_graph[v].append(u)

   _UpperCAmelCase				:	list[int]    						=    []
   _UpperCAmelCase				:	list[bool]    						=    [False] * n
   _UpperCAmelCase				:	list[int]    						=    []
   _UpperCAmelCase				:	list[int]    						=    []
   print(kosaraju())







import random






def    UpperCAmelCase__	(						lowerCamelCase  : Optional[Any]						):

   def is_sorted(lowerCamelCase  : Any						):
      for i in range(len(lowerCamelCase						) - 1						):
         if collection[i] > collection[i + 1]:
            return False
      return True

   while not is_sorted(lowerCamelCase						):
      random.shuffle(lowerCamelCase						)
   return collection


if __name__ == "__main__":
   _UpperCAmelCase				:	Any    						=    input('Enter numbers separated by a comma:\n').strip()
   _UpperCAmelCase				:	Optional[Any]    						=    [int(item) for item in user_input.split(',')]
   print(bogo_sort(unsorted))