


from __future__ import annotations

def       _a	(					SCREAMING_SNAKE_CASE						:					List[str]  ):







 """simple docstring"""



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

def       _a	(					SCREAMING_SNAKE_CASE						:					Any  ):







 """simple docstring"""



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

def       _a	(					):







 """simple docstring"""



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


if __name__ == "__main__":
       # n - no of nodes, m - no of edges
       __UpperCamelCase							,    __UpperCamelCase							:							Tuple    							=					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							:							List[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())






from typing import TYPE_CHECKING

from ...utils import (
    OptionalDependencyNotAvailable,
    _LazyModule,
    is_flax_available,
    is_tf_available,
    is_tokenizers_available,
    is_torch_available,
)


__UpperCamelCase							:							List[Any]    							=					{
    "configuration_mpnet": ["MPNET_PRETRAINED_CONFIG_ARCHIVE_MAP", "MPNetConfig"],
    "tokenization_mpnet": ["MPNetTokenizer"],
}

try:
       if not is_tokenizers_available():
              raise OptionalDependencyNotAvailable()
except OptionalDependencyNotAvailable:
       pass
else:
       __UpperCamelCase							:							Union[str, Any]    							=					["MPNetTokenizerFast"]

try:
       if not is_torch_available():
              raise OptionalDependencyNotAvailable()
except OptionalDependencyNotAvailable:
       pass
else:
       __UpperCamelCase							:							Union[str, Any]    							=					[
           "MPNET_PRETRAINED_MODEL_ARCHIVE_LIST",
           "MPNetForMaskedLM",
           "MPNetForMultipleChoice",
           "MPNetForQuestionAnswering",
           "MPNetForSequenceClassification",
           "MPNetForTokenClassification",
           "MPNetLayer",
           "MPNetModel",
           "MPNetPreTrainedModel",
       ]

try:
       if not is_tf_available():
              raise OptionalDependencyNotAvailable()
except OptionalDependencyNotAvailable:
       pass
else:
       __UpperCamelCase							:							List[Any]    							=					[
           "TF_MPNET_PRETRAINED_MODEL_ARCHIVE_LIST",
           "TFMPNetEmbeddings",
           "TFMPNetForMaskedLM",
           "TFMPNetForMultipleChoice",
           "TFMPNetForQuestionAnswering",
           "TFMPNetForSequenceClassification",
           "TFMPNetForTokenClassification",
           "TFMPNetMainLayer",
           "TFMPNetModel",
           "TFMPNetPreTrainedModel",
       ]


if TYPE_CHECKING:
       from .configuration_mpnet import MPNET_PRETRAINED_CONFIG_ARCHIVE_MAP, MPNetConfig
       from .tokenization_mpnet import MPNetTokenizer

       try:
              if not is_tokenizers_available():
                     raise OptionalDependencyNotAvailable()
       except OptionalDependencyNotAvailable:
              pass
       else:
              from .tokenization_mpnet_fast import MPNetTokenizerFast

       try:
              if not is_torch_available():
                     raise OptionalDependencyNotAvailable()
       except OptionalDependencyNotAvailable:
              pass
       else:
              from .modeling_mpnet import (
                  MPNET_PRETRAINED_MODEL_ARCHIVE_LIST,
                  MPNetForMaskedLM,
                  MPNetForMultipleChoice,
                  MPNetForQuestionAnswering,
                  MPNetForSequenceClassification,
                  MPNetForTokenClassification,
                  MPNetLayer,
                  MPNetModel,
                  MPNetPreTrainedModel,
              )

       try:
              if not is_tf_available():
                     raise OptionalDependencyNotAvailable()
       except OptionalDependencyNotAvailable:
              pass
       else:
              from .modeling_tf_mpnet import (
                  TF_MPNET_PRETRAINED_MODEL_ARCHIVE_LIST,
                  TFMPNetEmbeddings,
                  TFMPNetForMaskedLM,
                  TFMPNetForMultipleChoice,
                  TFMPNetForQuestionAnswering,
                  TFMPNetForSequenceClassification,
                  TFMPNetForTokenClassification,
                  TFMPNetMainLayer,
                  TFMPNetModel,
                  TFMPNetPreTrainedModel,
              )

else:
       import sys

       __UpperCamelCase							:							Tuple    							=					_LazyModule(__name__, globals()["__file__"], _import_structure, module_spec=__spec__)


