code: 
  
  
  
  
  
  
  from typing import List, Optional, Tuple, Union
  
  from . import logging
  from .import_utils import is_torch_available, is_torch_version
  
  
  if is_torch_available():
     import torch
  
  lowerCamelCase										=  logging.get_logger(__name__)  # pylint: disable=invalid-name
  
  try:
     from torch._dynamo import allow_in_graph as maybe_allow_in_graph
  except (ImportError, ModuleNotFoundError):
     def        UpperCAmelCase      (   cls      ):
  
  
         '''simple docstring'''
  
  
  
         return cls
  def        UpperCAmelCase      (   _lowercase,      _lowercase = None,      _lowercase = None,      _lowercase = None,      _lowercase = None,      ):
  
  
      '''simple docstring'''
  
  
  
      _lowercase     =	device
      _lowercase     =	shape[0]
  
      _lowercase     =	layout or torch.strided
      _lowercase     =	device or torch.device('cpu'      )
  
      if generator is not None:
          _lowercase     =	generator.device.type if not isinstance(_lowercase,      _lowercase      ) else generator[0].device.type
          if gen_device_type != device.type and gen_device_type == "cpu":
              _lowercase     =	'cpu'
              if device != "mps":
                  logger.info(
                      f'''The passed generator was created on \'cpu\' even though a tensor on {device} was expected.'''
                      f''' Tensors will be created on \'cpu\' and then moved to {device}. Note that one can probably'''
                      f''' slighly speed up this function by passing a generator that was created on the {device} device.'''      )
          elif gen_device_type != device.type and gen_device_type == "cuda":
              raise ValueError(f'''Cannot generate a {device} tensor from a generator of type {gen_device_type}.'''      )
  
      if isinstance(_lowercase,      _lowercase      ):
          _lowercase     =	(1,) + shape[1:]
          _lowercase     =	[
              torch.randn(_lowercase,      generator=generator[i],      device=_lowercase,      dtype=_lowercase,      layout=_lowercase      )
              for i in range(_lowercase      )
          ]
          _lowercase     =	torch.cat(_lowercase,      dim=0      ).to(_lowercase      )
      else:
          _lowercase     =	torch.randn(_lowercase,      generator=_lowercase,      device=_lowercase,      dtype=_lowercase,      layout=_lowercase      ).to(_lowercase      )
  
      return latents
  def        UpperCAmelCase      (   _lowercase      ):
  
  
      '''simple docstring'''
  
  
  
      if is_torch_version('<',      '2.0.0'      ) or not hasattr(_lowercase,      '_dynamo'      ):
          return False
      return isinstance(_lowercase,      torch._dynamo.eval_frame.OptimizedModule      )
  
style_context: 
  
  
  
  
  
  
  from __future__ import annotations
  def        UpperCAmelCase      (   _lowercase      ):
  
  
      '''simple docstring'''
  
  
  
      global graph, reversed_graph, scc, component, visit, stack
      if visit[u]:
          return
      _lowercase     =	True
      for v in graph[u]:
          dfs(_lowercase      )
      stack.append(_lowercase      )
  def        UpperCAmelCase      (   _lowercase      ):
  
  
      '''simple docstring'''
  
  
  
      global graph, reversed_graph, scc, component, visit, stack
      if visit[u]:
          return
      _lowercase     =	True
      component.append(_lowercase      )
      for v in reversed_graph[u]:
          dfsa(_lowercase      )
  def        UpperCAmelCase      (   ):
  
  
      '''simple docstring'''
  
  
  
      global graph, reversed_graph, scc, component, visit, stack
      for i in range(_lowercase      ):
          dfs(_lowercase      )
      _lowercase     =	[False] * n
      for i in stack[::-1]:
          if visit[i]:
              continue
          _lowercase     =	[]
          dfsa(_lowercase      )
          scc.append(_lowercase      )
      return scc
  
  
  if __name__ == "__main__":
     # n - no of nodes, m - no of edges
     lowerCamelCase						,		lowerCamelCase										=  list(map(int, input().strip().split()))
  
     lowerCamelCase										=  [[] for _ in range(n)]  # graph
     lowerCamelCase										=  [[] for i in range(n)]  # reversed graph
     # input graph data (edges)
     for _ in range(m):
        lowerCamelCase						,		lowerCamelCase										=  list(map(int, input().strip().split()))
        graph[u].append(v)
        reversed_graph[v].append(u)
  
     lowerCamelCase										=  []
     lowerCamelCase										=  [False] * n
     lowerCamelCase										=  []
     lowerCamelCase										=  []
     print(kosaraju())
  