






from collections import deque
from math import floor
from random import random
from time import time







class 		_A						:

  def __init__(    self						:	int			):
     """simple docstring"""

     __UpperCamelCase	:			List[Any]					=					{}

  def    a					(    self						:	Any   ,				lowerCamelCase__						:	Dict   ,				lowerCamelCase__						:	Union[str, Any]   ,				lowerCamelCase__						:	Union[str, Any]=1			):
     """simple docstring"""

     if self.graph.get(lowerCamelCase__			):
        if self.graph[u].count([w, v]			) == 0:
           self.graph[u].append([w, v]			)
     else:
        __UpperCamelCase	:			Dict					=					[[w, v]]
     if not self.graph.get(lowerCamelCase__			):
        __UpperCamelCase	:			List[str]					=					[]

  def    a					(    self						:	Optional[int]			):
     """simple docstring"""

     return list(self.graph			)

  def    a					(    self						:	Any   ,				lowerCamelCase__						:	List[str]   ,				lowerCamelCase__						:	str			):
     """simple docstring"""

     if self.graph.get(lowerCamelCase__			):
        for _ in self.graph[u]:
           if _[1] == v:
              self.graph[u].remove(lowerCamelCase__			)

  def    a					(    self						:	Union[str, Any]   ,				lowerCamelCase__						:	List[str]=-2   ,				lowerCamelCase__						:	Optional[Any]=-1			):
     """simple docstring"""

     if s == d:
        return []
     __UpperCamelCase	:			Optional[Any]					=					[]
     __UpperCamelCase	:			Tuple					=					[]
     if s == -2:
        __UpperCamelCase	:			Optional[Any]					=					list(self.graph			)[0]
     stack.append(lowerCamelCase__			)
     visited.append(lowerCamelCase__			)
     __UpperCamelCase	:			int					=					s

     while True:
        # check if there is any non isolated nodes
        if len(self.graph[s]			) != 0:
           __UpperCamelCase	:			Optional[int]					=					s
           for node in self.graph[s]:
              if visited.count(node[1]			) < 1:
                 if node[1] == d:
                    visited.append(lowerCamelCase__			)
                    return visited
                 else:
                    stack.append(node[1]			)
                    visited.append(node[1]			)
                    __UpperCamelCase	:			List[Any]					=					node[1]
                    break

            # check if all the children are visited
        if s == ss:
           stack.pop()
           if len(lowerCamelCase__			) != 0:
              __UpperCamelCase	:			List[str]					=					stack[len(lowerCamelCase__			) - 1]
        else:
           __UpperCamelCase	:			Union[str, Any]					=					ss

        # check if se have reached the starting point
        if len(lowerCamelCase__			) == 0:
           return visited

  def    a					(    self						:	Tuple   ,				lowerCamelCase__						:	Optional[Any]=-1			):
     """simple docstring"""

     if c == -1:
        __UpperCamelCase	:			List[str]					=					floor(random() * 1_00_00			) + 10
     for i in range(lowerCamelCase__			):
        # every vertex has max 100 edges
        for _ in range(floor(random() * 1_02			) + 1			):
           __UpperCamelCase	:			int					=					floor(random() * c			) + 1
           if n != i:
              self.add_pair(lowerCamelCase__   ,				lowerCamelCase__   ,				1			)

  def    a					(    self						:	str   ,				lowerCamelCase__						:	List[Any]=-2			):
     """simple docstring"""

     __UpperCamelCase	:			Any					=					deque()
     __UpperCamelCase	:			List[str]					=					[]
     if s == -2:
        __UpperCamelCase	:			int					=					list(self.graph			)[0]
     d.append(lowerCamelCase__			)
     visited.append(lowerCamelCase__			)
     while d:
        __UpperCamelCase	:			Tuple					=					d.popleft()
        if len(self.graph[s]			) != 0:
           for node in self.graph[s]:
              if visited.count(node[1]			) < 1:
                 d.append(node[1]			)
                 visited.append(node[1]			)
     return visited

  def    a					(    self						:	Dict   ,				lowerCamelCase__						:	Optional[Any]			):
     """simple docstring"""

     __UpperCamelCase	:			int					=					0
     for x in self.graph:
        for y in self.graph[x]:
           if y[1] == u:
              count += 1
     return count

  def    a					(    self						:	Tuple   ,				lowerCamelCase__						:	Union[str, Any]			):
     """simple docstring"""

     return len(self.graph[u]			)

  def    a					(    self						:	List[str]   ,				lowerCamelCase__						:	int=-2			):
     """simple docstring"""

     __UpperCamelCase	:			Optional[Any]					=					[]
     __UpperCamelCase	:			List[Any]					=					[]
     if s == -2:
        __UpperCamelCase	:			str					=					list(self.graph			)[0]
     stack.append(lowerCamelCase__			)
     visited.append(lowerCamelCase__			)
     __UpperCamelCase	:			List[str]					=					s
     __UpperCamelCase	:			Tuple					=					[]

     while True:
        # check if there is any non isolated nodes
        if len(self.graph[s]			) != 0:
           __UpperCamelCase	:			Optional[int]					=					s
           for node in self.graph[s]:
              if visited.count(node[1]			) < 1:
                 stack.append(node[1]			)
                 visited.append(node[1]			)
                 __UpperCamelCase	:			List[Any]					=					node[1]
                 break

            # check if all the children are visited
        if s == ss:
           sorted_nodes.append(stack.pop()			)
           if len(lowerCamelCase__			) != 0:
              __UpperCamelCase	:			Dict					=					stack[len(lowerCamelCase__			) - 1]
        else:
           __UpperCamelCase	:			List[str]					=					ss

        # check if se have reached the starting point
        if len(lowerCamelCase__			) == 0:
           return sorted_nodes

  def    a					(    self						:	Union[str, Any]			):
     """simple docstring"""

     __UpperCamelCase	:			Tuple					=					[]
     __UpperCamelCase	:			List[str]					=					[]
     __UpperCamelCase	:			Union[str, Any]					=					list(self.graph			)[0]
     stack.append(lowerCamelCase__			)
     visited.append(lowerCamelCase__			)
     __UpperCamelCase	:			Union[str, Any]					=					-2
     __UpperCamelCase	:			List[Any]					=					[]
     __UpperCamelCase	:			int					=					s
     __UpperCamelCase	:			str					=					False
     __UpperCamelCase	:			Union[str, Any]					=					set()

     while True:
        # check if there is any non isolated nodes
        if len(self.graph[s]			) != 0:
           __UpperCamelCase	:			int					=					s
           for node in self.graph[s]:
              if (
                  visited.count(node[1]			) > 0
                  and node[1] != parent
                  and indirect_parents.count(node[1]			) > 0
                  and not on_the_way_back
              ):
                 __UpperCamelCase	:			Optional[int]					=					len(lowerCamelCase__			) - 1
                 while len_stack >= 0:
                    if stack[len_stack] == node[1]:
                       anticipating_nodes.add(node[1]			)
                       break
                    else:
                       anticipating_nodes.add(stack[len_stack]			)
                       len_stack -= 1
              if visited.count(node[1]			) < 1:
                 stack.append(node[1]			)
                 visited.append(node[1]			)
                 __UpperCamelCase	:			Tuple					=					node[1]
                 break

            # check if all the children are visited
        if s == ss:
           stack.pop()
           __UpperCamelCase	:			Any					=					True
           if len(lowerCamelCase__			) != 0:
              __UpperCamelCase	:			int					=					stack[len(lowerCamelCase__			) - 1]
        else:
           __UpperCamelCase	:			Optional[int]					=					False
           indirect_parents.append(lowerCamelCase__			)
           __UpperCamelCase	:			Optional[int]					=					s
           __UpperCamelCase	:			str					=					ss

        # check if se have reached the starting point
        if len(lowerCamelCase__			) == 0:
           return list(lowerCamelCase__			)

  def    a					(    self						:	List[str]			):
     """simple docstring"""

     __UpperCamelCase	:			Any					=					[]
     __UpperCamelCase	:			int					=					[]
     __UpperCamelCase	:			str					=					list(self.graph			)[0]
     stack.append(lowerCamelCase__			)
     visited.append(lowerCamelCase__			)
     __UpperCamelCase	:			Any					=					-2
     __UpperCamelCase	:			int					=					[]
     __UpperCamelCase	:			List[Any]					=					s
     __UpperCamelCase	:			str					=					False
     __UpperCamelCase	:			int					=					set()

     while True:
        # check if there is any non isolated nodes
        if len(self.graph[s]			) != 0:
           __UpperCamelCase	:			Tuple					=					s
           for node in self.graph[s]:
              if (
                  visited.count(node[1]			) > 0
                  and node[1] != parent
                  and indirect_parents.count(node[1]			) > 0
                  and not on_the_way_back
              ):
                 __UpperCamelCase	:			Optional[int]					=					len(lowerCamelCase__			) - 1
                 while len_stack_minus_one >= 0:
                    if stack[len_stack_minus_one] == node[1]:
                       anticipating_nodes.add(node[1]			)
                       break
                    else:
                       return True
              if visited.count(node[1]			) < 1:
                 stack.append(node[1]			)
                 visited.append(node[1]			)
                 __UpperCamelCase	:			int					=					node[1]
                 break

            # check if all the children are visited
        if s == ss:
           stack.pop()
           __UpperCamelCase	:			int					=					True
           if len(lowerCamelCase__			) != 0:
              __UpperCamelCase	:			List[Any]					=					stack[len(lowerCamelCase__			) - 1]
        else:
           __UpperCamelCase	:			Tuple					=					False
           indirect_parents.append(lowerCamelCase__			)
           __UpperCamelCase	:			Optional[Any]					=					s
           __UpperCamelCase	:			str					=					ss

        # check if se have reached the starting point
        if len(lowerCamelCase__			) == 0:
           return False

  def    a					(    self						:	Dict   ,				lowerCamelCase__						:	Tuple=-2   ,				lowerCamelCase__						:	Any=-1			):
     """simple docstring"""

     __UpperCamelCase	:			Tuple					=					time()
     self.dfs(lowerCamelCase__   ,				lowerCamelCase__			)
     __UpperCamelCase	:			List[str]					=					time()
     return end - begin

  def    a					(    self						:	Any   ,				lowerCamelCase__						:	str=-2			):
     """simple docstring"""

     __UpperCamelCase	:			Union[str, Any]					=					time()
     self.bfs(lowerCamelCase__			)
     __UpperCamelCase	:			Any					=					time()
     return end - begin







class 		_A						:

  def __init__(    self						:	int			):
     """simple docstring"""

     __UpperCamelCase	:			Optional[Any]					=					{}

  def    a					(    self						:	Optional[int]   ,				lowerCamelCase__						:	Any   ,				lowerCamelCase__						:	str   ,				lowerCamelCase__						:	int=1			):
     """simple docstring"""

     if self.graph.get(lowerCamelCase__			):
        # if there already is a edge
        if self.graph[u].count([w, v]			) == 0:
           self.graph[u].append([w, v]			)
     else:
        # if u does not exist
        __UpperCamelCase	:			Dict					=					[[w, v]]
     # add the other way
     if self.graph.get(lowerCamelCase__			):
        # if there already is a edge
        if self.graph[v].count([w, u]			) == 0:
           self.graph[v].append([w, u]			)
     else:
        # if u does not exist
        __UpperCamelCase	:			int					=					[[w, u]]

  def    a					(    self						:	Union[str, Any]   ,				lowerCamelCase__						:	Any   ,				lowerCamelCase__						:	List[str]			):
     """simple docstring"""

     if self.graph.get(lowerCamelCase__			):
        for _ in self.graph[u]:
           if _[1] == v:
              self.graph[u].remove(lowerCamelCase__			)
        # the other way round
     if self.graph.get(lowerCamelCase__			):
        for _ in self.graph[v]:
           if _[1] == u:
              self.graph[v].remove(lowerCamelCase__			)

  def    a					(    self						:	Union[str, Any]   ,				lowerCamelCase__						:	Optional[Any]=-2   ,				lowerCamelCase__						:	int=-1			):
     """simple docstring"""

     if s == d:
        return []
     __UpperCamelCase	:			Union[str, Any]					=					[]
     __UpperCamelCase	:			Tuple					=					[]
     if s == -2:
        __UpperCamelCase	:			str					=					list(self.graph			)[0]
     stack.append(lowerCamelCase__			)
     visited.append(lowerCamelCase__			)
     __UpperCamelCase	:			Dict					=					s

     while True:
        # check if there is any non isolated nodes
        if len(self.graph[s]			) != 0:
           __UpperCamelCase	:			Optional[int]					=					s
           for node in self.graph[s]:
              if visited.count(node[1]			) < 1:
                 if node[1] == d:
                    visited.append(lowerCamelCase__			)
                    return visited
                 else:
                    stack.append(node[1]			)
                    visited.append(node[1]			)
                    __UpperCamelCase	:			Union[str, Any]					=					node[1]
                    break

            # check if all the children are visited
        if s == ss:
           stack.pop()
           if len(lowerCamelCase__			) != 0:
              __UpperCamelCase	:			Any					=					stack[len(lowerCamelCase__			) - 1]
        else:
           __UpperCamelCase	:			Any					=					ss

        # check if se have reached the starting point
        if len(lowerCamelCase__			) == 0:
           return visited

  def    a					(    self						:	Tuple   ,				lowerCamelCase__						:	Optional[int]=-1			):
     """simple docstring"""

     if c == -1:
        __UpperCamelCase	:			List[str]					=					floor(random() * 1_00_00			) + 10
     for i in range(lowerCamelCase__			):
        # every vertex has max 100 edges
        for _ in range(floor(random() * 1_02			) + 1			):
           __UpperCamelCase	:			Tuple					=					floor(random() * c			) + 1
           if n != i:
              self.add_pair(lowerCamelCase__   ,				lowerCamelCase__   ,				1			)

  def    a					(    self						:	Any   ,				lowerCamelCase__						:	int=-2			):
     """simple docstring"""

     __UpperCamelCase	:			str					=					deque()
     __UpperCamelCase	:			int					=					[]
     if s == -2:
        __UpperCamelCase	:			Tuple					=					list(self.graph			)[0]
     d.append(lowerCamelCase__			)
     visited.append(lowerCamelCase__			)
     while d:
        __UpperCamelCase	:			Any					=					d.popleft()
        if len(self.graph[s]			) != 0:
           for node in self.graph[s]:
              if visited.count(node[1]			) < 1:
                 d.append(node[1]			)
                 visited.append(node[1]			)
     return visited

  def    a					(    self						:	Optional[Any]   ,				lowerCamelCase__						:	List[str]			):
     """simple docstring"""

     return len(self.graph[u]			)

  def    a					(    self						:	Union[str, Any]			):
     """simple docstring"""

     __UpperCamelCase	:			str					=					[]
     __UpperCamelCase	:			str					=					[]
     __UpperCamelCase	:			Optional[int]					=					list(self.graph			)[0]
     stack.append(lowerCamelCase__			)
     visited.append(lowerCamelCase__			)
     __UpperCamelCase	:			Optional[Any]					=					-2
     __UpperCamelCase	:			List[str]					=					[]
     __UpperCamelCase	:			int					=					s
     __UpperCamelCase	:			Union[str, Any]					=					False
     __UpperCamelCase	:			Union[str, Any]					=					set()

     while True:
        # check if there is any non isolated nodes
        if len(self.graph[s]			) != 0:
           __UpperCamelCase	:			str					=					s
           for node in self.graph[s]:
              if (
                  visited.count(node[1]			) > 0
                  and node[1] != parent
                  and indirect_parents.count(node[1]			) > 0
                  and not on_the_way_back
              ):
                 __UpperCamelCase	:			Tuple					=					len(lowerCamelCase__			) - 1
                 while len_stack >= 0:
                    if stack[len_stack] == node[1]:
                       anticipating_nodes.add(node[1]			)
                       break
                    else:
                       anticipating_nodes.add(stack[len_stack]			)
                       len_stack -= 1
              if visited.count(node[1]			) < 1:
                 stack.append(node[1]			)
                 visited.append(node[1]			)
                 __UpperCamelCase	:			Union[str, Any]					=					node[1]
                 break

            # check if all the children are visited
        if s == ss:
           stack.pop()
           __UpperCamelCase	:			Union[str, Any]					=					True
           if len(lowerCamelCase__			) != 0:
              __UpperCamelCase	:			Dict					=					stack[len(lowerCamelCase__			) - 1]
        else:
           __UpperCamelCase	:			int					=					False
           indirect_parents.append(lowerCamelCase__			)
           __UpperCamelCase	:			Dict					=					s
           __UpperCamelCase	:			Union[str, Any]					=					ss

        # check if se have reached the starting point
        if len(lowerCamelCase__			) == 0:
           return list(lowerCamelCase__			)

  def    a					(    self						:	str			):
     """simple docstring"""

     __UpperCamelCase	:			List[str]					=					[]
     __UpperCamelCase	:			Optional[Any]					=					[]
     __UpperCamelCase	:			str					=					list(self.graph			)[0]
     stack.append(lowerCamelCase__			)
     visited.append(lowerCamelCase__			)
     __UpperCamelCase	:			int					=					-2
     __UpperCamelCase	:			Optional[Any]					=					[]
     __UpperCamelCase	:			Any					=					s
     __UpperCamelCase	:			str					=					False
     __UpperCamelCase	:			List[str]					=					set()

     while True:
        # check if there is any non isolated nodes
        if len(self.graph[s]			) != 0:
           __UpperCamelCase	:			Any					=					s
           for node in self.graph[s]:
              if (
                  visited.count(node[1]			) > 0
                  and node[1] != parent
                  and indirect_parents.count(node[1]			) > 0
                  and not on_the_way_back
              ):
                 __UpperCamelCase	:			Dict					=					len(lowerCamelCase__			) - 1
                 while len_stack_minus_one >= 0:
                    if stack[len_stack_minus_one] == node[1]:
                       anticipating_nodes.add(node[1]			)
                       break
                    else:
                       return True
              if visited.count(node[1]			) < 1:
                 stack.append(node[1]			)
                 visited.append(node[1]			)
                 __UpperCamelCase	:			Dict					=					node[1]
                 break

            # check if all the children are visited
        if s == ss:
           stack.pop()
           __UpperCamelCase	:			List[str]					=					True
           if len(lowerCamelCase__			) != 0:
              __UpperCamelCase	:			Optional[Any]					=					stack[len(lowerCamelCase__			) - 1]
        else:
           __UpperCamelCase	:			Optional[Any]					=					False
           indirect_parents.append(lowerCamelCase__			)
           __UpperCamelCase	:			Any					=					s
           __UpperCamelCase	:			Optional[int]					=					ss

        # check if se have reached the starting point
        if len(lowerCamelCase__			) == 0:
           return False

  def    a					(    self						:	int			):
     """simple docstring"""

     return list(self.graph			)

  def    a					(    self						:	List[Any]   ,				lowerCamelCase__						:	Dict=-2   ,				lowerCamelCase__						:	Optional[Any]=-1			):
     """simple docstring"""

     __UpperCamelCase	:			Tuple					=					time()
     self.dfs(lowerCamelCase__   ,				lowerCamelCase__			)
     __UpperCamelCase	:			str					=					time()
     return end - begin

  def    a					(    self						:	Union[str, Any]   ,				lowerCamelCase__						:	int=-2			):
     """simple docstring"""

     __UpperCamelCase	:			Dict					=					time()
     self.bfs(lowerCamelCase__			)
     __UpperCamelCase	:			Tuple					=					time()
     return end - begin











from . import (
    albert,
    align,
    altclip,
    audio_spectrogram_transformer,
    auto,
    autoformer,
    bark,
    bart,
    barthez,
    bartpho,
    beit,
    bert,
    bert_generation,
    bert_japanese,
    bertweet,
    big_bird,
    bigbird_pegasus,
    biogpt,
    bit,
    blenderbot,
    blenderbot_small,
    blip,
    blip_a,
    bloom,
    bridgetower,
    byta,
    camembert,
    canine,
    chinese_clip,
    clap,
    clip,
    clipseg,
    codegen,
    conditional_detr,
    convbert,
    convnext,
    convnextva,
    cpm,
    cpmant,
    ctrl,
    cvt,
    dataavec,
    deberta,
    deberta_va,
    decision_transformer,
    deformable_detr,
    deit,
    deprecated,
    deta,
    detr,
    dialogpt,
    dinat,
    distilbert,
    dit,
    donut,
    dpr,
    dpt,
    efficientformer,
    efficientnet,
    electra,
    encodec,
    encoder_decoder,
    ernie,
    ernie_m,
    esm,
    falcon,
    flaubert,
    flava,
    fnet,
    focalnet,
    fsmt,
    funnel,
    git,
    glpn,
    gpta,
    gpt_bigcode,
    gpt_neo,
    gpt_neox,
    gpt_neox_japanese,
    gpt_swa,
    gptj,
    gptsan_japanese,
    graphormer,
    groupvit,
    herbert,
    hubert,
    ibert,
    imagegpt,
    informer,
    instructblip,
    jukebox,
    layoutlm,
    layoutlmva,
    layoutlmva,
    layoutxlm,
    led,
    levit,
    lilt,
    llama,
    longformer,
    longta,
    luke,
    lxmert,
    mam_aaa,
    marian,
    markuplm,
    maskaformer,
    maskformer,
    mbart,
    mbartaa,
    mega,
    megatron_bert,
    megatron_gpta,
    mgp_str,
    mluke,
    mobilebert,
    mobilenet_va,
    mobilenet_va,
    mobilevit,
    mobilevitva,
    mpnet,
    mra,
    mta,
    musicgen,
    mvp,
    nat,
    nezha,
    nllb,
    nllb_moe,
    nystromformer,
    oneformer,
    open_llama,
    openai,
    opt,
    owlvit,
    pegasus,
    pegasus_x,
    perceiver,
    phobert,
    pixastruct,
    plbart,
    poolformer,
    prophetnet,
    qdqbert,
    rag,
    realm,
    reformer,
    regnet,
    rembert,
    resnet,
    roberta,
    roberta_prelayernorm,
    roc_bert,
    roformer,
    rwkv,
    sam,
    segformer,
    sew,
    sew_d,
    speech_encoder_decoder,
    speech_to_text,
    speech_to_text_a,
    speechta,
    splinter,
    squeezebert,
    swiftformer,
    swin,
    swinasr,
    swinva,
    switch_transformers,
    ta,
    table_transformer,
    tapas,
    time_series_transformer,
    timesformer,
    timm_backbone,
    transfo_xl,
    trocr,
    tvlt,
    umta,
    unispeech,
    unispeech_sat,
    upernet,
    videomae,
    vilt,
    vision_encoder_decoder,
    vision_text_dual_encoder,
    visual_bert,
    vit,
    vit_hybrid,
    vit_mae,
    vit_msn,
    vivit,
    wavaveca,
    wavaveca_conformer,
    wavaveca_phoneme,
    wavaveca_with_lm,
    wavlm,
    whisper,
    x_clip,
    xglm,
    xlm,
    xlm_prophetnet,
    xlm_roberta,
    xlm_roberta_xl,
    xlnet,
    xmod,
    yolos,
    yoso,
)



