






"""simple docstring"""
from __future__ import annotations






def        lowerCamelCase_  (						_lowerCamelCase				):
 global graph, reversed_graph, scc, component, visit, stack
 if visit[u]:
  return
 lowerCamelCase__     :			List[str]     				=						True
 for v in graph[u]:
  dfs(_lowerCamelCase				)
 stack.append(_lowerCamelCase				)






def        lowerCamelCase_  (						_lowerCamelCase				):
 global graph, reversed_graph, scc, component, visit, stack
 if visit[u]:
  return
 lowerCamelCase__     :			Tuple     				=						True
 component.append(_lowerCamelCase				)
 for v in reversed_graph[u]:
  dfsa(_lowerCamelCase				)






def        lowerCamelCase_  (						):
 global graph, reversed_graph, scc, component, visit, stack
 for i in range(_lowerCamelCase				):
  dfs(_lowerCamelCase				)
 lowerCamelCase__     :			Tuple     				=						[False] * n
 for i in stack[::-1]:
  if visit[i]:
   continue
  lowerCamelCase__     :			Tuple     				=						[]
  dfsa(_lowerCamelCase				)
  scc.append(_lowerCamelCase				)
 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_			: Optional[int]				=			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())









"""simple docstring"""
from typing import TYPE_CHECKING

from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_torch_available


A_			: Dict				=			{"configuration_qdqbert": ["QDQBERT_PRETRAINED_CONFIG_ARCHIVE_MAP", "QDQBertConfig"]}

try:
      if not is_torch_available():
            raise OptionalDependencyNotAvailable()
except OptionalDependencyNotAvailable:
      pass
else:
      A_			: Tuple				=			[
          "QDQBERT_PRETRAINED_MODEL_ARCHIVE_LIST",
          "QDQBertForMaskedLM",
          "QDQBertForMultipleChoice",
          "QDQBertForNextSentencePrediction",
          "QDQBertForQuestionAnswering",
          "QDQBertForSequenceClassification",
          "QDQBertForTokenClassification",
          "QDQBertLayer",
          "QDQBertLMHeadModel",
          "QDQBertModel",
          "QDQBertPreTrainedModel",
          "load_tf_weights_in_qdqbert",
      ]


if TYPE_CHECKING:
      from .configuration_qdqbert import QDQBERT_PRETRAINED_CONFIG_ARCHIVE_MAP, QDQBertConfig

      try:
            if not is_torch_available():
                  raise OptionalDependencyNotAvailable()
      except OptionalDependencyNotAvailable:
            pass
      else:
            from .modeling_qdqbert import (
                QDQBERT_PRETRAINED_MODEL_ARCHIVE_LIST,
                QDQBertForMaskedLM,
                QDQBertForMultipleChoice,
                QDQBertForNextSentencePrediction,
                QDQBertForQuestionAnswering,
                QDQBertForSequenceClassification,
                QDQBertForTokenClassification,
                QDQBertLayer,
                QDQBertLMHeadModel,
                QDQBertModel,
                QDQBertPreTrainedModel,
                load_tf_weights_in_qdqbert,
            )


else:
      import sys

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

