
from typing import Dict, List, Optional, Union

import numpy as np

from ...image_processing_utils import BaseImageProcessor, BatchFeature, get_size_dict
from ...image_transforms import center_crop, normalize, rescale, resize, to_channel_dimension_format
from ...image_utils import (
    IMAGENET_STANDARD_MEAN,
    IMAGENET_STANDARD_STD,
    ChannelDimension,
    ImageInput,
    PILImageResampling,
    make_list_of_images,
    to_numpy_array,
    valid_images,
)
from ...utils import TensorType, is_vision_available, logging


if is_vision_available():
 import PIL


SCREAMING_SNAKE_CASE		:Any				  =    logging.get_logger(__name__)






class 	__magic_name__				(       lowerCamelCase__							):
     UpperCamelCase_  :str								=			["""pixel_values"""]






     def __init__(							self		,	_lowercase = True		,	_lowercase = None		,	_lowercase = PIL.Image.NEAREST		,	_lowercase = False		,	_lowercase = None		,	_lowercase = 1 / 255		,	_lowercase = False		,	_lowercase = True		,	_lowercase = True		,	_lowercase = None		,	_lowercase = None		,	_lowercase = True		,	**_lowercase		,	)->    Union[str, Any]:
         super().__init__(**SCREAMING_SNAKE_CASE_  )
         UpperCamelCase_      =	size if size is not None else {"height": 346, "width": 346}
         UpperCamelCase_      =	get_size_dict(SCREAMING_SNAKE_CASE_  )
         UpperCamelCase_      =	crop_size if crop_size is not None else {"height": 289, "width": 289}
         UpperCamelCase_      =	get_size_dict(SCREAMING_SNAKE_CASE_		,	param_name="crop_size"  )

         UpperCamelCase_      =	do_resize
         UpperCamelCase_      =	size
         UpperCamelCase_      =	resample
         UpperCamelCase_      =	do_center_crop
         UpperCamelCase_      =	crop_size
         UpperCamelCase_      =	do_rescale
         UpperCamelCase_      =	rescale_factor
         UpperCamelCase_      =	rescale_offset
         UpperCamelCase_      =	do_normalize
         UpperCamelCase_      =	image_mean if image_mean is not None else IMAGENET_STANDARD_MEAN
         UpperCamelCase_      =	image_std if image_std is not None else IMAGENET_STANDARD_STD
         UpperCamelCase_      =	include_top






     def   UpperCAmelCase_							(							self		,	_lowercase		,	_lowercase		,	_lowercase = PIL.Image.NEAREST		,	_lowercase = None		,	**_lowercase		,	)->    List[str]:
         UpperCamelCase_      =	get_size_dict(SCREAMING_SNAKE_CASE_  )
         if "height" not in size or "width" not in size:
             raise ValueError(F"The size dictionary must have keys 'height' and 'width'. Got {size.keys()}"  )
         return resize(
             SCREAMING_SNAKE_CASE_		,	size=(size["height"], size["width"])		,	resample=SCREAMING_SNAKE_CASE_		,	data_format=SCREAMING_SNAKE_CASE_		,	**SCREAMING_SNAKE_CASE_  )






     def   UpperCAmelCase_							(							self		,	_lowercase		,	_lowercase		,	_lowercase = None		,	**_lowercase		,	)->    Tuple:
         UpperCamelCase_      =	get_size_dict(SCREAMING_SNAKE_CASE_  )
         if "height" not in size or "width" not in size:
             raise ValueError(F"The size dictionary must have keys 'height' and 'width'. Got {size.keys()}"  )
         return center_crop(SCREAMING_SNAKE_CASE_		,	size=(size["height"], size["width"])		,	data_format=SCREAMING_SNAKE_CASE_		,	**SCREAMING_SNAKE_CASE_  )






     def   UpperCAmelCase_							(							self		,	_lowercase		,	_lowercase		,	_lowercase = True		,	_lowercase = None		,	**_lowercase		,	)->    Optional[int]:
         if offset:
             UpperCamelCase_      =	(image - 127.5) * scale
             if data_format is not None:
                 UpperCamelCase_      =	to_channel_dimension_format(SCREAMING_SNAKE_CASE_		,	SCREAMING_SNAKE_CASE_  )
             UpperCamelCase_      =	rescaled_image.astype(np.floataa  )
         else:
             UpperCamelCase_      =	rescale(SCREAMING_SNAKE_CASE_		,	scale=SCREAMING_SNAKE_CASE_		,	data_format=SCREAMING_SNAKE_CASE_		,	**SCREAMING_SNAKE_CASE_  )
         return rescaled_image






     def   UpperCAmelCase_							(							self		,	_lowercase		,	_lowercase		,	_lowercase		,	_lowercase = None		,	**_lowercase		,	)->    Tuple:
         return normalize(SCREAMING_SNAKE_CASE_		,	mean=SCREAMING_SNAKE_CASE_		,	std=SCREAMING_SNAKE_CASE_		,	data_format=SCREAMING_SNAKE_CASE_		,	**SCREAMING_SNAKE_CASE_  )






     def   UpperCAmelCase_							(							self		,	_lowercase		,	_lowercase = None		,	_lowercase = None		,	_lowercase=None		,	_lowercase = None		,	_lowercase = None		,	_lowercase = None		,	_lowercase = None		,	_lowercase = None		,	_lowercase = None		,	_lowercase = None		,	_lowercase = None		,	_lowercase = None		,	_lowercase = None		,	_lowercase = ChannelDimension.FIRST		,	**_lowercase		,	)->    Any:
         UpperCamelCase_      =	do_resize if do_resize is not None else self.do_resize
         UpperCamelCase_      =	resample if resample is not None else self.resample
         UpperCamelCase_      =	do_center_crop if do_center_crop is not None else self.do_center_crop
         UpperCamelCase_      =	do_rescale if do_rescale is not None else self.do_rescale
         UpperCamelCase_      =	rescale_factor if rescale_factor is not None else self.rescale_factor
         UpperCamelCase_      =	rescale_offset if rescale_offset is not None else self.rescale_offset
         UpperCamelCase_      =	do_normalize if do_normalize is not None else self.do_normalize
         UpperCamelCase_      =	image_mean if image_mean is not None else self.image_mean
         UpperCamelCase_      =	image_std if image_std is not None else self.image_std
         UpperCamelCase_      =	include_top if include_top is not None else self.include_top

         UpperCamelCase_      =	size if size is not None else self.size
         UpperCamelCase_      =	get_size_dict(SCREAMING_SNAKE_CASE_  )
         UpperCamelCase_      =	crop_size if crop_size is not None else self.crop_size
         UpperCamelCase_      =	get_size_dict(SCREAMING_SNAKE_CASE_		,	param_name="crop_size"  )

         UpperCamelCase_      =	make_list_of_images(SCREAMING_SNAKE_CASE_  )

         if not valid_images(SCREAMING_SNAKE_CASE_  ):
             raise ValueError(
                 "Invalid image type. Must be of type PIL.Image.Image, numpy.ndarray, "
                 "torch.Tensor, tf.Tensor or jax.ndarray."  )

         if do_resize and size is None or resample is None:
             raise ValueError("Size and resample must be specified if do_resize is True."  )

         if do_center_crop and crop_size is None:
             raise ValueError("Crop size must be specified if do_center_crop is True."  )

         if do_rescale and rescale_factor is None:
             raise ValueError("Rescale factor must be specified if do_rescale is True."  )

         if do_normalize and (image_mean is None or image_std is None):
             raise ValueError("Image mean and std must be specified if do_normalize is True."  )

         # All transformations expect numpy arrays.
         UpperCamelCase_      =	[to_numpy_array(SCREAMING_SNAKE_CASE_  ) for image in images]

         if do_resize:
             UpperCamelCase_      =	[self.resize(image=SCREAMING_SNAKE_CASE_		,	size=SCREAMING_SNAKE_CASE_		,	resample=SCREAMING_SNAKE_CASE_  ) for image in images]

         if do_center_crop:
             UpperCamelCase_      =	[self.center_crop(image=SCREAMING_SNAKE_CASE_		,	size=SCREAMING_SNAKE_CASE_  ) for image in images]

         if do_rescale:
             UpperCamelCase_      =	[self.rescale(image=SCREAMING_SNAKE_CASE_		,	scale=SCREAMING_SNAKE_CASE_		,	offset=SCREAMING_SNAKE_CASE_  ) for image in images]

         if do_normalize:
             UpperCamelCase_      =	[self.normalize(image=SCREAMING_SNAKE_CASE_		,	mean=SCREAMING_SNAKE_CASE_		,	std=SCREAMING_SNAKE_CASE_  ) for image in images]

         if include_top:
             UpperCamelCase_      =	[self.normalize(image=SCREAMING_SNAKE_CASE_		,	mean=[0, 0, 0]		,	std=SCREAMING_SNAKE_CASE_  ) for image in images]

         UpperCamelCase_      =	[to_channel_dimension_format(SCREAMING_SNAKE_CASE_		,	SCREAMING_SNAKE_CASE_  ) for image in images]

         UpperCamelCase_      =	{"pixel_values": images}
         return BatchFeature(data=SCREAMING_SNAKE_CASE_		,	tensor_type=SCREAMING_SNAKE_CASE_  )



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())
