
from __future__ import annotations




def 				__SCREAMING_SNAKE_CASE  (						SCREAMING_SNAKE_CASE			: Optional[Any]     )	->		Tuple:
				global graph, reversed_graph, scc, component, visit, stack
				if visit[u]:
								return
				__lowercase								=   True
				for v in graph[u]:
								dfs(SCREAMING_SNAKE_CASE     )
				stack.append(SCREAMING_SNAKE_CASE     )




def 				__SCREAMING_SNAKE_CASE  (						SCREAMING_SNAKE_CASE			: Any     )	->		Union[str, Any]:
				global graph, reversed_graph, scc, component, visit, stack
				if visit[u]:
								return
				__lowercase								=   True
				component.append(SCREAMING_SNAKE_CASE     )
				for v in reversed_graph[u]:
								dfsa(SCREAMING_SNAKE_CASE     )




def 				__SCREAMING_SNAKE_CASE  (						)	->		Optional[Any]:
				global graph, reversed_graph, scc, component, visit, stack
				for i in range(SCREAMING_SNAKE_CASE     ):
								dfs(SCREAMING_SNAKE_CASE     )
				__lowercase								=   [False] * n
				for i in stack[::-1]:
								if visit[i]:
												continue
								__lowercase								=   []
								dfsa(SCREAMING_SNAKE_CASE     )
								scc.append(SCREAMING_SNAKE_CASE     )
				return scc


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

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

							SCREAMING_SNAKE_CASE__				=							[]
							SCREAMING_SNAKE_CASE__				=							[False] * n
							SCREAMING_SNAKE_CASE__				=							[]
							SCREAMING_SNAKE_CASE__				=							[]
							print(kosaraju())







from ..utils import DummyObject, requires_backends
class       A__  (		metaclass=lowerCAmelCase__							):
							lowerCAmelCase__						:		Tuple            =				["torch", "transformers", "invisible_watermark"]





							def __init__(					self    :  Any	,					*_UpperCAmelCase    :  Optional[Any]	,					**_UpperCAmelCase    :  List[str]							)		->						Tuple:



											"""simple docstring"""


											requires_backends(self	,					['torch', 'transformers', 'invisible_watermark']							)





							@classmethod
							def      a__					(					cls    :  str	,					*_UpperCAmelCase    :  List[str]	,					**_UpperCAmelCase    :  Optional[Any]							)		->						Union[str, Any]:



											"""simple docstring"""


											requires_backends(cls	,					['torch', 'transformers', 'invisible_watermark']							)





							@classmethod
							def      a__					(					cls    :  List[Any]	,					*_UpperCAmelCase    :  List[Any]	,					**_UpperCAmelCase    :  Union[str, Any]							)		->						str:



											"""simple docstring"""


											requires_backends(cls	,					['torch', 'transformers', 'invisible_watermark']							)






class       A__  (		metaclass=lowerCAmelCase__							):
							lowerCAmelCase__						:		Tuple            =				["torch", "transformers", "invisible_watermark"]





							def __init__(					self    :  Dict	,					*_UpperCAmelCase    :  Optional[int]	,					**_UpperCAmelCase    :  Any							)		->						Union[str, Any]:



											"""simple docstring"""


											requires_backends(self	,					['torch', 'transformers', 'invisible_watermark']							)





							@classmethod
							def      a__					(					cls    :  List[str]	,					*_UpperCAmelCase    :  Union[str, Any]	,					**_UpperCAmelCase    :  Optional[Any]							)		->						Optional[int]:



											"""simple docstring"""


											requires_backends(cls	,					['torch', 'transformers', 'invisible_watermark']							)





							@classmethod
							def      a__					(					cls    :  Tuple	,					*_UpperCAmelCase    :  List[Any]	,					**_UpperCAmelCase    :  Tuple							)		->						Any:



											"""simple docstring"""


											requires_backends(cls	,					['torch', 'transformers', 'invisible_watermark']							)





