






'''simple docstring'''
from __future__ import annotations




def 						__SCREAMING_SNAKE_CASE   (					_UpperCamelCase							):


   """simple docstring"""




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




def 						__SCREAMING_SNAKE_CASE   (					_UpperCamelCase							):


   """simple docstring"""




   global graph, reversed_graph, scc, component, visit, stack
   if visit[u]:
      return
   lowercase_		:      Optional[int]          =       True
   component.append(_UpperCamelCase							)
   for v in reversed_graph[u]:
      dfsa(_UpperCamelCase							)




def 						__SCREAMING_SNAKE_CASE   (					):


   """simple docstring"""




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


if __name__ == "__main__":
 # n - no of nodes, m - no of edges
 UpperCamelCase__,       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__,       UpperCamelCase__	=     list(map(int, input().strip().split()))
  graph[u].append(v)
  reversed_graph[v].append(u)

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











'''simple docstring'''
from typing import TYPE_CHECKING

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


UpperCamelCase__	=     {
    'configuration_unispeech_sat': ['UNISPEECH_SAT_PRETRAINED_CONFIG_ARCHIVE_MAP', 'UniSpeechSatConfig'],
}

try:
 if not is_torch_available():
  raise OptionalDependencyNotAvailable()
except OptionalDependencyNotAvailable:
 pass
else:
 UpperCamelCase__	=     [
     'UNISPEECH_SAT_PRETRAINED_MODEL_ARCHIVE_LIST',
     'UniSpeechSatForAudioFrameClassification',
     'UniSpeechSatForCTC',
     'UniSpeechSatForPreTraining',
     'UniSpeechSatForSequenceClassification',
     'UniSpeechSatForXVector',
     'UniSpeechSatModel',
     'UniSpeechSatPreTrainedModel',
 ]

if TYPE_CHECKING:
 from .configuration_unispeech_sat import UNISPEECH_SAT_PRETRAINED_CONFIG_ARCHIVE_MAP, UniSpeechSatConfig

 try:
  if not is_torch_available():
   raise OptionalDependencyNotAvailable()
 except OptionalDependencyNotAvailable:
  pass
 else:
  from .modeling_unispeech_sat import (
      UNISPEECH_SAT_PRETRAINED_MODEL_ARCHIVE_LIST,
      UniSpeechSatForAudioFrameClassification,
      UniSpeechSatForCTC,
      UniSpeechSatForPreTraining,
      UniSpeechSatForSequenceClassification,
      UniSpeechSatForXVector,
      UniSpeechSatModel,
      UniSpeechSatPreTrainedModel,
  )

else:
 import sys

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




