
"""simple docstring"""

import argparse

import torch

from transformers import ElectraConfig, ElectraForMaskedLM, ElectraForPreTraining, load_tf_weights_in_electra
from transformers.utils import logging


logging.set_verbosity_info()




def 			lowercase__  (    lowerCAmelCase :    Optional[int]       , lowerCAmelCase :    int       , lowerCAmelCase :    List[Any]       , lowerCAmelCase :    List[Any]       )       ->					Tuple:






    """simple docstring"""




    UpperCAmelCase  	=    ElectraConfig.from_json_file(lowerCAmelCase       )
    print(F"Building PyTorch model from configuration: {config}"       )

    if discriminator_or_generator == "discriminator":
        UpperCAmelCase  	=    ElectraForPreTraining(lowerCAmelCase       )
    elif discriminator_or_generator == "generator":
        UpperCAmelCase  	=    ElectraForMaskedLM(lowerCAmelCase       )
    else:
        raise ValueError('The discriminator_or_generator argument should be either \'discriminator\' or \'generator\''       )

    # Load weights from tf checkpoint
    load_tf_weights_in_electra(
        lowerCAmelCase       , lowerCAmelCase       , lowerCAmelCase       , discriminator_or_generator=lowerCAmelCase       )

    # Save pytorch-model
    print(F"Save PyTorch model to {pytorch_dump_path}"       )
    torch.save(model.state_dict()       , lowerCAmelCase       )


if __name__ == "__main__":
   SCREAMING_SNAKE_CASE_			    =  argparse.ArgumentParser()
   # Required parameters
   parser.add_argument(
       '''--tf_checkpoint_path''', default=None, type=str, required=True, help='''Path to the TensorFlow checkpoint path.'''
   )
   parser.add_argument(
       '''--config_file''',
       default=None,
       type=str,
       required=True,
       help='''The config json file corresponding to the pre-trained model. \nThis specifies the model architecture.''',
   )
   parser.add_argument(
       '''--pytorch_dump_path''', default=None, type=str, required=True, help='''Path to the output PyTorch model.'''
   )
   parser.add_argument(
       '''--discriminator_or_generator''',
       default=None,
       type=str,
       required=True,
       help=(
           '''Whether to export the generator or the discriminator. Should be a string, either \'discriminator\' or '''
           '''\'generator\'.'''
       ),
   )
   SCREAMING_SNAKE_CASE_			    =  parser.parse_args()
   convert_tf_checkpoint_to_pytorch(
       args.tf_checkpoint_path, args.config_file, args.pytorch_dump_path, args.discriminator_or_generator
   )





"""simple docstring"""

from __future__ import annotations




def 			lowercase__  (    lowerCAmelCase :    Dict       )       ->					Optional[int]:






    """simple docstring"""




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




def 			lowercase__  (    lowerCAmelCase :    Optional[int]       )       ->					int:






    """simple docstring"""




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




def 			lowercase__  (    )       ->					List[str]:






    """simple docstring"""




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


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

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

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



