






from __future__ import annotations



def      UpperCAmelCase						( lowerCAmelCase__	):


		'''simple docstring'''

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



def      UpperCAmelCase						( lowerCAmelCase__	):


		'''simple docstring'''

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



def      UpperCAmelCase						( ):


		'''simple docstring'''

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


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

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

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



'''simple docstring'''


from typing import TYPE_CHECKING

from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_tokenizers_available, is_torch_available


__SCREAMING_SNAKE_CASE						=      {
    "configuration_markuplm": ["MARKUPLM_PRETRAINED_CONFIG_ARCHIVE_MAP", "MarkupLMConfig"],
    "feature_extraction_markuplm": ["MarkupLMFeatureExtractor"],
    "processing_markuplm": ["MarkupLMProcessor"],
    "tokenization_markuplm": ["MarkupLMTokenizer"],
}

try:
	if not is_tokenizers_available():
		raise OptionalDependencyNotAvailable()
except OptionalDependencyNotAvailable:
	pass
else:
	__SCREAMING_SNAKE_CASE						=      ["MarkupLMTokenizerFast"]

try:
	if not is_torch_available():
		raise OptionalDependencyNotAvailable()
except OptionalDependencyNotAvailable:
	pass
else:
	__SCREAMING_SNAKE_CASE						=      [
	    "MARKUPLM_PRETRAINED_MODEL_ARCHIVE_LIST",
	    "MarkupLMForQuestionAnswering",
	    "MarkupLMForSequenceClassification",
	    "MarkupLMForTokenClassification",
	    "MarkupLMModel",
	    "MarkupLMPreTrainedModel",
	]


if TYPE_CHECKING:
	from .configuration_markuplm import MARKUPLM_PRETRAINED_CONFIG_ARCHIVE_MAP, MarkupLMConfig
	from .feature_extraction_markuplm import MarkupLMFeatureExtractor
	from .processing_markuplm import MarkupLMProcessor
	from .tokenization_markuplm import MarkupLMTokenizer

	try:
		if not is_tokenizers_available():
			raise OptionalDependencyNotAvailable()
	except OptionalDependencyNotAvailable:
		pass
	else:
		from .tokenization_markuplm_fast import MarkupLMTokenizerFast

	try:
		if not is_torch_available():
			raise OptionalDependencyNotAvailable()
	except OptionalDependencyNotAvailable:
		pass
	else:
		from .modeling_markuplm import (
		    MARKUPLM_PRETRAINED_MODEL_ARCHIVE_LIST,
		    MarkupLMForQuestionAnswering,
		    MarkupLMForSequenceClassification,
		    MarkupLMForTokenClassification,
		    MarkupLMModel,
		    MarkupLMPreTrainedModel,
		)


else:
	import sys

	__SCREAMING_SNAKE_CASE						=      _LazyModule(__name__, globals()["__file__"], _import_structure)




