


from __future__ import annotations
def     UpperCAmelCase_ (							__snake_case						)					->      Dict:







 """simple docstring"""


 global graph, reversed_graph, scc, component, visit, stack
 if visit[u]:
  return
 _lowercase											=True
 for v in graph[u]:
  dfs(_lowerCAmelCase						)
 stack.append(_lowerCAmelCase						)
def     UpperCAmelCase_ (							__snake_case						)					->      Union[str, Any]:







 """simple docstring"""


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







 """simple docstring"""


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


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

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

  UpperCAmelCase__            =							[]
  UpperCAmelCase__            =							[False] * n
  UpperCAmelCase__            =							[]
  UpperCAmelCase__            =							[]
  print(kosaraju())








from typing import TYPE_CHECKING

from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_torch_available


UpperCAmelCase__            =							{'''configuration_visual_bert''': ['''VISUAL_BERT_PRETRAINED_CONFIG_ARCHIVE_MAP''', '''VisualBertConfig''']}

try:
  if not is_torch_available():
    raise OptionalDependencyNotAvailable()
except OptionalDependencyNotAvailable:
  pass
else:
  UpperCAmelCase__            =							[
      '''VISUAL_BERT_PRETRAINED_MODEL_ARCHIVE_LIST''',
      '''VisualBertForMultipleChoice''',
      '''VisualBertForPreTraining''',
      '''VisualBertForQuestionAnswering''',
      '''VisualBertForRegionToPhraseAlignment''',
      '''VisualBertForVisualReasoning''',
      '''VisualBertLayer''',
      '''VisualBertModel''',
      '''VisualBertPreTrainedModel''',
  ]


if TYPE_CHECKING:
  from .configuration_visual_bert import VISUAL_BERT_PRETRAINED_CONFIG_ARCHIVE_MAP, VisualBertConfig

  try:
    if not is_torch_available():
      raise OptionalDependencyNotAvailable()
  except OptionalDependencyNotAvailable:
    pass
  else:
    from .modeling_visual_bert import (
        VISUAL_BERT_PRETRAINED_MODEL_ARCHIVE_LIST,
        VisualBertForMultipleChoice,
        VisualBertForPreTraining,
        VisualBertForQuestionAnswering,
        VisualBertForRegionToPhraseAlignment,
        VisualBertForVisualReasoning,
        VisualBertLayer,
        VisualBertModel,
        VisualBertPreTrainedModel,
    )


else:
  import sys

  UpperCAmelCase__            =							_LazyModule(__name__, globals()['''__file__'''], _import_structure, module_spec=__spec__)

