


from __future__ import annotations



def 			_a      (    __UpperCamelCase			):
     global graph, reversed_graph, scc, component, visit, stack
     if visit[u]:
          return
     a_     :  Optional[Any]				      =     True
     for v in graph[u]:
          dfs(__UpperCamelCase			)
     stack.append(__UpperCamelCase			)



def 			_a      (    __UpperCamelCase			):
     global graph, reversed_graph, scc, component, visit, stack
     if visit[u]:
          return
     a_     :  Optional[Any]				      =     True
     component.append(__UpperCamelCase			)
     for v in reversed_graph[u]:
          dfsa(__UpperCamelCase			)



def 			_a      (    ):
     global graph, reversed_graph, scc, component, visit, stack
     for i in range(__UpperCamelCase			):
          dfs(__UpperCamelCase			)
     a_     :  Tuple				      =     [False] * n
     for i in stack[::-1]:
          if visit[i]:
               continue
          a_     :  str				      =     []
          dfsa(__UpperCamelCase			)
          scc.append(__UpperCamelCase			)
     return scc


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

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





from dataclasses import dataclass
from typing import List, Optional, Union

import numpy as np
import PIL

from ...utils import BaseOutput, is_invisible_watermark_available, is_torch_available, is_transformers_available


@dataclass
class 							lowercase   (						_SCREAMING_SNAKE_CASE  ):
		__lowercase			:			Union[List[PIL.Image.Image], np.ndarray]


if is_transformers_available() and is_torch_available() and is_invisible_watermark_available():
					from .pipeline_stable_diffusion_xl import StableDiffusionXLPipeline
					from .pipeline_stable_diffusion_xl_imgaimg import StableDiffusionXLImgaImgPipeline
