
'''simple docstring'''





def     snake_case							(						UpperCAmelCase ,					UpperCAmelCase ,					UpperCAmelCase		)->     Tuple:







						"""simple docstring"""
						__A    		=     index
						__A    		=     2 * index + 1
						__A    		=     2 * index + 2
						if left_index < heap_size and unsorted[left_index] > unsorted[largest]:
												__A    		=     left_index

						if right_index < heap_size and unsorted[right_index] > unsorted[largest]:
												__A    		=     right_index

						if largest != index:
												__A		, __A    		=     unsorted[index], unsorted[largest]
												heapify(UpperCAmelCase ,					UpperCAmelCase ,					UpperCAmelCase		)





def     snake_case							(						UpperCAmelCase		)->     int:







						"""simple docstring"""
						__A    		=     len(UpperCAmelCase		)
						for i in range(n // 2 - 1 ,					-1 ,					-1		):
												heapify(UpperCAmelCase ,					UpperCAmelCase ,					UpperCAmelCase		)
						for i in range(n - 1 ,					0 ,					-1		):
												__A		, __A    		=     unsorted[i], unsorted[0]
												heapify(UpperCAmelCase ,					0 ,					UpperCAmelCase		)
						return unsorted


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








'''simple docstring'''





from __future__ import annotations





def     snake_case							(						UpperCAmelCase		)->     List[Any]:







      """simple docstring"""
      global graph, reversed_graph, scc, component, visit, stack
      if visit[u]:
            return
      __A    		=     True
      for v in graph[u]:
            dfs(UpperCAmelCase		)
      stack.append(UpperCAmelCase		)





def     snake_case							(						UpperCAmelCase		)->     List[Any]:







      """simple docstring"""
      global graph, reversed_graph, scc, component, visit, stack
      if visit[u]:
            return
      __A    		=     True
      component.append(UpperCAmelCase		)
      for v in reversed_graph[u]:
            dfsa(UpperCAmelCase		)





def     snake_case							(						)->     Any:







      """simple docstring"""
      global graph, reversed_graph, scc, component, visit, stack
      for i in range(UpperCAmelCase		):
            dfs(UpperCAmelCase		)
      __A    		=     [False] * n
      for i in stack[::-1]:
            if visit[i]:
                  continue
            __A    		=     []
            dfsa(UpperCAmelCase		)
            scc.append(UpperCAmelCase		)
      return scc


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

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

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






