



from __future__ import annotations


def     UpperCamelCase(						__UpperCamelCase							:	str				):
		global graph, reversed_graph, scc, component, visit, stack
		if visit[u]:
				return
		lowerCAmelCase_    :  Any             =				True
		for v in graph[u]:
				dfs(__UpperCamelCase				)
		stack.append(__UpperCamelCase				)


def     UpperCamelCase(						__UpperCamelCase							:	Any				):
		global graph, reversed_graph, scc, component, visit, stack
		if visit[u]:
				return
		lowerCAmelCase_    :  Optional[int]             =				True
		component.append(__UpperCamelCase				)
		for v in reversed_graph[u]:
				dfsa(__UpperCamelCase				)


def     UpperCamelCase(						):
		global graph, reversed_graph, scc, component, visit, stack
		for i in range(__UpperCamelCase				):
				dfs(__UpperCamelCase				)
		lowerCAmelCase_    :  List[Any]             =				[False] * n
		for i in stack[::-1]:
				if visit[i]:
						continue
				lowerCAmelCase_    :  Optional[int]             =				[]
				dfsa(__UpperCamelCase				)
				scc.append(__UpperCamelCase				)
		return scc


if __name__ == "__main__":
						# n - no of nodes, m - no of edges
						A__      ,  A__						:						Any          =      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__						:						Dict          =      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())










from typing import TYPE_CHECKING

from ...utils import (
    OptionalDependencyNotAvailable,
    _LazyModule,
    is_tf_available,
    is_torch_available,
    is_vision_available,
)


A__						:						List[str]          =      {
    '''configuration_segformer''': ['''SEGFORMER_PRETRAINED_CONFIG_ARCHIVE_MAP''', '''SegformerConfig''', '''SegformerOnnxConfig''']
}

try:
						if not is_vision_available():
												raise OptionalDependencyNotAvailable()
except OptionalDependencyNotAvailable:
						pass
else:
						A__						:						int          =      ['''SegformerFeatureExtractor''']
						A__						:						Dict          =      ['''SegformerImageProcessor''']

try:
						if not is_torch_available():
												raise OptionalDependencyNotAvailable()
except OptionalDependencyNotAvailable:
						pass
else:
						A__						:						Any          =      [
						    '''SEGFORMER_PRETRAINED_MODEL_ARCHIVE_LIST''',
						    '''SegformerDecodeHead''',
						    '''SegformerForImageClassification''',
						    '''SegformerForSemanticSegmentation''',
						    '''SegformerLayer''',
						    '''SegformerModel''',
						    '''SegformerPreTrainedModel''',
						]

try:
						if not is_tf_available():
												raise OptionalDependencyNotAvailable()
except OptionalDependencyNotAvailable:
						pass
else:
						A__						:						List[Any]          =      [
						    '''TF_SEGFORMER_PRETRAINED_MODEL_ARCHIVE_LIST''',
						    '''TFSegformerDecodeHead''',
						    '''TFSegformerForImageClassification''',
						    '''TFSegformerForSemanticSegmentation''',
						    '''TFSegformerModel''',
						    '''TFSegformerPreTrainedModel''',
						]


if TYPE_CHECKING:
						from .configuration_segformer import SEGFORMER_PRETRAINED_CONFIG_ARCHIVE_MAP, SegformerConfig, SegformerOnnxConfig

						try:
												if not is_vision_available():
																		raise OptionalDependencyNotAvailable()
						except OptionalDependencyNotAvailable:
												pass
						else:
												from .feature_extraction_segformer import SegformerFeatureExtractor
												from .image_processing_segformer import SegformerImageProcessor

						try:
												if not is_torch_available():
																		raise OptionalDependencyNotAvailable()
						except OptionalDependencyNotAvailable:
												pass
						else:
												from .modeling_segformer import (
												    SEGFORMER_PRETRAINED_MODEL_ARCHIVE_LIST,
												    SegformerDecodeHead,
												    SegformerForImageClassification,
												    SegformerForSemanticSegmentation,
												    SegformerLayer,
												    SegformerModel,
												    SegformerPreTrainedModel,
												)
						try:
												if not is_tf_available():
																		raise OptionalDependencyNotAvailable()
						except OptionalDependencyNotAvailable:
												pass
						else:
												from .modeling_tf_segformer import (
												    TF_SEGFORMER_PRETRAINED_MODEL_ARCHIVE_LIST,
												    TFSegformerDecodeHead,
												    TFSegformerForImageClassification,
												    TFSegformerForSemanticSegmentation,
												    TFSegformerModel,
												    TFSegformerPreTrainedModel,
												)

else:
						import sys

						A__						:						Dict          =      _LazyModule(__name__, globals()['''__file__'''], _import_structure, module_spec=__spec__)





