


'''simple docstring'''



from __future__ import annotations



def       UpperCAmelCase__ (     UpperCAmelCase_   :    List[Any]							)					->		int:
     global graph, reversed_graph, scc, component, visit, stack
     if visit[u]:
          return
     __lowerCamelCase       :     str        =		True
     for v in graph[u]:
          dfs(UpperCAmelCase_							)
     stack.append(UpperCAmelCase_							)



def       UpperCAmelCase__ (     UpperCAmelCase_   :    List[str]							)					->		List[str]:
     global graph, reversed_graph, scc, component, visit, stack
     if visit[u]:
          return
     __lowerCamelCase       :     List[str]        =		True
     component.append(UpperCAmelCase_							)
     for v in reversed_graph[u]:
          dfsa(UpperCAmelCase_							)



def       UpperCAmelCase__ (     )					->		Tuple:
     global graph, reversed_graph, scc, component, visit, stack
     for i in range(UpperCAmelCase_							):
          dfs(UpperCAmelCase_							)
     __lowerCamelCase       :     Tuple        =		[False] * n
     for i in stack[::-1]:
          if visit[i]:
               continue
          __lowerCamelCase       :     int        =		[]
          dfsa(UpperCAmelCase_							)
          scc.append(UpperCAmelCase_							)
     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__		: Union[str, Any]												=  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_tf_available, is_torch_available


A__		: str												=  {"""configuration_hubert""": ["""HUBERT_PRETRAINED_CONFIG_ARCHIVE_MAP""", """HubertConfig"""]}

try:
      if not is_torch_available():
            raise OptionalDependencyNotAvailable()
except OptionalDependencyNotAvailable:
      pass
else:
      A__		: List[str]												=  [
          """HUBERT_PRETRAINED_MODEL_ARCHIVE_LIST""",
          """HubertForCTC""",
          """HubertForSequenceClassification""",
          """HubertModel""",
          """HubertPreTrainedModel""",
      ]


try:
      if not is_tf_available():
            raise OptionalDependencyNotAvailable()
except OptionalDependencyNotAvailable:
      pass
else:
      A__		: Optional[int]												=  [
          """TF_HUBERT_PRETRAINED_MODEL_ARCHIVE_LIST""",
          """TFHubertForCTC""",
          """TFHubertModel""",
          """TFHubertPreTrainedModel""",
      ]

if TYPE_CHECKING:
      from .configuration_hubert import HUBERT_PRETRAINED_CONFIG_ARCHIVE_MAP, HubertConfig

      try:
            if not is_torch_available():
                  raise OptionalDependencyNotAvailable()
      except OptionalDependencyNotAvailable:
            pass
      else:
            from .modeling_hubert import (
                HUBERT_PRETRAINED_MODEL_ARCHIVE_LIST,
                HubertForCTC,
                HubertForSequenceClassification,
                HubertModel,
                HubertPreTrainedModel,
            )

      try:
            if not is_tf_available():
                  raise OptionalDependencyNotAvailable()
      except OptionalDependencyNotAvailable:
            pass
      else:
            from .modeling_tf_hubert import (
                TF_HUBERT_PRETRAINED_MODEL_ARCHIVE_LIST,
                TFHubertForCTC,
                TFHubertModel,
                TFHubertPreTrainedModel,
            )


else:
      import sys

      A__		: Optional[int]												=  _LazyModule(__name__, globals()["""__file__"""], _import_structure, module_spec=__spec__)






