

from typing import Callable, Optional, Union

from ...configuration_utils import PretrainedConfig
from ...utils import logging


SCREAMING_SNAKE_CASE		:int				  =    logging.get_logger(__name__)

SCREAMING_SNAKE_CASE		:Union[str, Any]				  =    {
    """microsoft/prophetnet-large-uncased""": (
        """https://huggingface.co/microsoft/prophetnet-large-uncased/resolve/main/config.json"""
    ),
}






class 	__magic_name__				(       snake_case							):
     UpperCamelCase_  :Optional[Any]								=			"""prophetnet"""
     UpperCamelCase_  :List[str]								=			["""past_key_values"""]
     UpperCamelCase_  :Any								=			{
         """num_attention_heads""": """num_encoder_attention_heads""",
     }






     def __init__(							self		,	_lowercase = 0.1		,	_lowercase = "gelu"		,	_lowercase = 30_522		,	_lowercase = 1_024		,	_lowercase = 4_096		,	_lowercase = 12		,	_lowercase = 16		,	_lowercase = 4_096		,	_lowercase = 12		,	_lowercase = 16		,	_lowercase = 0.1		,	_lowercase = 0.1		,	_lowercase = 512		,	_lowercase = 0.02		,	_lowercase = True		,	_lowercase = True		,	_lowercase = 0		,	_lowercase = 2		,	_lowercase = 32		,	_lowercase = 128		,	_lowercase = False		,	_lowercase = 0.0		,	_lowercase = True		,	_lowercase = 0		,	_lowercase = 1		,	_lowercase = 2		,	**_lowercase		,	)->    Any:
         UpperCamelCase_      =	vocab_size
         UpperCamelCase_      =	hidden_size
         UpperCamelCase_      =	encoder_ffn_dim
         UpperCamelCase_      =	num_encoder_layers
         UpperCamelCase_      =	num_encoder_attention_heads
         UpperCamelCase_      =	decoder_ffn_dim
         UpperCamelCase_      =	num_decoder_layers
         UpperCamelCase_      =	num_decoder_attention_heads
         UpperCamelCase_      =	max_position_embeddings
         UpperCamelCase_      =	init_std  # Normal(0, this parameter)
         UpperCamelCase_      =	activation_function

         # parameters for prophetnet
         UpperCamelCase_      =	ngram
         UpperCamelCase_      =	num_buckets
         UpperCamelCase_      =	relative_max_distance
         UpperCamelCase_      =	disable_ngram_loss
         UpperCamelCase_      =	eps

         # 3 Types of Dropout
         UpperCamelCase_      =	attention_dropout
         UpperCamelCase_      =	activation_dropout
         UpperCamelCase_      =	dropout

         UpperCamelCase_      =	use_cache

         super().__init__(
             pad_token_id=_lowercase		,	bos_token_id=_lowercase		,	eos_token_id=_lowercase		,	is_encoder_decoder=_lowercase		,	add_cross_attention=_lowercase		,	decoder_start_token_id=_lowercase		,	**_lowercase		,	)






     @property
     def   UpperCAmelCase_							(							self  )->    int:
         return self.num_encoder_layers + self.num_decoder_layers






     @num_hidden_layers.setter
     def   UpperCAmelCase_							(							self		,	_lowercase  )->    str:
         raise NotImplementedError(
             "This model does not support the setting of `num_hidden_layers`. Please set `num_encoder_layers` and"
             " `num_decoder_layers`."  )



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