
import numpy as np
from cva import COLOR_BGR2GRAY, cvtColor, imread, imshow, waitKey

from digital_image_processing.filters.convolve import img_convolve




def  lowerCAmelCase(			SCREAMING_SNAKE_CASE_ )->	Union[str, Any]:



    """simple docstring"""






    UpperCamelCase_      =	np.array([[-1, 0, 1], [-2, 0, 2], [-1, 0, 1]] )
    UpperCamelCase_      =	np.array([[1, 2, 1], [0, 0, 0], [-1, -2, -1]] )

    UpperCamelCase_      =	np.abs(img_convolve(UpperCamelCase_ ,	UpperCamelCase_ ) )
    UpperCamelCase_      =	np.abs(img_convolve(UpperCamelCase_ ,	UpperCamelCase_ ) )
    # modify the pix within [0, 255]
    UpperCamelCase_      =	dst_x * 2_5_5 / np.max(UpperCamelCase_ )
    UpperCamelCase_      =	dst_y * 2_5_5 / np.max(UpperCamelCase_ )

    UpperCamelCase_      =	np.sqrt((np.square(UpperCamelCase_ )) + (np.square(UpperCamelCase_ )) )
    UpperCamelCase_      =	dst_xy * 2_5_5 / np.max(UpperCamelCase_ )
    UpperCamelCase_      =	dst_xy.astype(np.uinta )

    UpperCamelCase_      =	np.arctana(UpperCamelCase_ ,	UpperCamelCase_ )
    return dst, theta


if __name__ == "__main__":
 # read original image
 SCREAMING_SNAKE_CASE		:Optional[Any]				  =    imread("""../image_data/lena.jpg""")
 # turn image in gray scale value
 SCREAMING_SNAKE_CASE		:Union[str, Any]				  =    cvtColor(img, COLOR_BGR2GRAY)

 SCREAMING_SNAKE_CASE		:Any				  =    sobel_filter(gray)

 # show result images
 imshow("""sobel filter""", sobel_grad)
 imshow("""sobel theta""", sobel_theta)
 waitKey(0)



from __future__ import annotations




def  lowerCAmelCase(			SCREAMING_SNAKE_CASE_ )->	str:



    """simple docstring"""






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




def  lowerCAmelCase(			SCREAMING_SNAKE_CASE_ )->	Dict:



    """simple docstring"""






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




def  lowerCAmelCase(			)->	Dict:



    """simple docstring"""






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


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

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

 SCREAMING_SNAKE_CASE		:list[int]				  =    []
 SCREAMING_SNAKE_CASE		:list[bool]				  =    [False] * n
 SCREAMING_SNAKE_CASE		:list[int]				  =    []
 SCREAMING_SNAKE_CASE		:list[int]				  =    []
 print(kosaraju())
