


'''simple docstring'''

from collections import deque
from math import floor
from random import random
from time import time
class _lowerCamelCase	:



  '''simple docstring'''







  def __init__( self		:						Optional[Any]      )  ->			int:
   __magic_name__	:   List[str]					     =					{}







  def        __lowerCAmelCase		( self		:						Any  ,					_A		:						Dict  ,					_A		:						List[Any]  ,					_A		:						List[str]=1      )  ->			Any:







   if self.graph.get(_A      ):
    if self.graph[u].count([w, v]      ) == 0:
     self.graph[u].append([w, v]      )
   else:
    __magic_name__	:   Union[str, Any]					     =					[[w, v]]
   if not self.graph.get(_A      ):
    __magic_name__	:   str					     =					[]







  def        __lowerCAmelCase		( self		:						Union[str, Any]      )  ->			List[Any]:
   return list(self.graph      )







  def        __lowerCAmelCase		( self		:						Union[str, Any]  ,					_A		:						Tuple  ,					_A		:						Optional[Any]      )  ->			Tuple:







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







  def        __lowerCAmelCase		( self		:						Any  ,					_A		:						str=-2  ,					_A		:						Tuple=-1      )  ->			List[Any]:







   if s == d:
    return []
   __magic_name__	:   List[Any]					     =					[]
   __magic_name__	:   int					     =					[]
   if s == -2:
    __magic_name__	:   Any					     =					list(self.graph      )[0]
   stack.append(_A      )
   visited.append(_A      )
   __magic_name__	:   Optional[Any]					     =					s

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

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

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







  def        __lowerCAmelCase		( self		:						List[str]  ,					_A		:						int=-1      )  ->			Optional[Any]:







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







  def        __lowerCAmelCase		( self		:						List[str]  ,					_A		:						List[Any]=-2      )  ->			Union[str, Any]:
   __magic_name__	:   Tuple					     =					deque()
   __magic_name__	:   int					     =					[]
   if s == -2:
    __magic_name__	:   Dict					     =					list(self.graph      )[0]
   d.append(_A      )
   visited.append(_A      )
   while d:
    __magic_name__	:   Dict					     =					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        __lowerCAmelCase		( self		:						str  ,					_A		:						List[Any]      )  ->			Optional[int]:
   __magic_name__	:   Dict					     =					0
   for x in self.graph:
    for y in self.graph[x]:
     if y[1] == u:
      count += 1
   return count







  def        __lowerCAmelCase		( self		:						Any  ,					_A		:						int      )  ->			List[Any]:
   return len(self.graph[u]      )







  def        __lowerCAmelCase		( self		:						Tuple  ,					_A		:						List[Any]=-2      )  ->			Any:
   __magic_name__	:   Any					     =					[]
   __magic_name__	:   int					     =					[]
   if s == -2:
    __magic_name__	:   Any					     =					list(self.graph      )[0]
   stack.append(_A      )
   visited.append(_A      )
   __magic_name__	:   List[str]					     =					s
   __magic_name__	:   Any					     =					[]

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

            # check if all the children are visited
    if s == ss:
     sorted_nodes.append(stack.pop()      )
     if len(_A      ) != 0:
      __magic_name__	:   Any					     =					stack[len(_A      ) - 1]
    else:
     __magic_name__	:   int					     =					ss

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







  def        __lowerCAmelCase		( self		:						int      )  ->			int:
   __magic_name__	:   Any					     =					[]
   __magic_name__	:   Optional[Any]					     =					[]
   __magic_name__	:   List[Any]					     =					list(self.graph      )[0]
   stack.append(_A      )
   visited.append(_A      )
   __magic_name__	:   List[Any]					     =					-2
   __magic_name__	:   Optional[int]					     =					[]
   __magic_name__	:   List[str]					     =					s
   __magic_name__	:   List[str]					     =					False
   __magic_name__	:   int					     =					set()

   while True:
    # check if there is any non isolated nodes
    if len(self.graph[s]      ) != 0:
     __magic_name__	:   Union[str, 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
      ):
       __magic_name__	:   Union[str, Any]					     =					len(_A      ) - 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]      )
       __magic_name__	:   Tuple					     =					node[1]
       break

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

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







  def        __lowerCAmelCase		( self		:						Optional[Any]      )  ->			Dict:
   __magic_name__	:   str					     =					[]
   __magic_name__	:   Optional[Any]					     =					[]
   __magic_name__	:   str					     =					list(self.graph      )[0]
   stack.append(_A      )
   visited.append(_A      )
   __magic_name__	:   Optional[Any]					     =					-2
   __magic_name__	:   Tuple					     =					[]
   __magic_name__	:   Optional[int]					     =					s
   __magic_name__	:   Optional[Any]					     =					False
   __magic_name__	:   Any					     =					set()

   while True:
    # check if there is any non isolated nodes
    if len(self.graph[s]      ) != 0:
     __magic_name__	:   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
      ):
       __magic_name__	:   Dict					     =					len(_A      ) - 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]      )
       __magic_name__	:   Optional[int]					     =					node[1]
       break

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

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







  def        __lowerCAmelCase		( self		:						int  ,					_A		:						str=-2  ,					_A		:						List[Any]=-1      )  ->			Union[str, Any]:
   __magic_name__	:   int					     =					time()
   self.dfs(_A  ,					_A      )
   __magic_name__	:   Optional[Any]					     =					time()
   return end - begin







  def        __lowerCAmelCase		( self		:						Optional[int]  ,					_A		:						Optional[Any]=-2      )  ->			Any:
   __magic_name__	:   List[str]					     =					time()
   self.bfs(_A      )
   __magic_name__	:   Union[str, Any]					     =					time()
   return end - begin







class _lowerCamelCase	:



  '''simple docstring'''







  def __init__( self		:						Optional[int]      )  ->			Optional[int]:
   __magic_name__	:   int					     =					{}







  def        __lowerCAmelCase		( self		:						Optional[Any]  ,					_A		:						Any  ,					_A		:						Optional[int]  ,					_A		:						str=1      )  ->			Any:







   if self.graph.get(_A      ):
    # 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
    __magic_name__	:   Dict					     =					[[w, v]]
   # add the other way
   if self.graph.get(_A      ):
    # 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
    __magic_name__	:   List[str]					     =					[[w, u]]







  def        __lowerCAmelCase		( self		:						Optional[Any]  ,					_A		:						str  ,					_A		:						Dict      )  ->			Union[str, Any]:







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







  def        __lowerCAmelCase		( self		:						Union[str, Any]  ,					_A		:						Any=-2  ,					_A		:						Tuple=-1      )  ->			List[str]:







   if s == d:
    return []
   __magic_name__	:   List[str]					     =					[]
   __magic_name__	:   Any					     =					[]
   if s == -2:
    __magic_name__	:   List[str]					     =					list(self.graph      )[0]
   stack.append(_A      )
   visited.append(_A      )
   __magic_name__	:   List[str]					     =					s

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

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

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







  def        __lowerCAmelCase		( self		:						int  ,					_A		:						Optional[Any]=-1      )  ->			List[str]:







   if c == -1:
    __magic_name__	:   List[Any]					     =					floor(random() * 10000      ) + 10
   for i in range(_A      ):
    # every vertex has max 100 edges
    for _ in range(floor(random() * 102      ) + 1      ):
     __magic_name__	:   int					     =					floor(random() * c      ) + 1
     if n != i:
      self.add_pair(_A  ,					_A  ,					1      )







  def        __lowerCAmelCase		( self		:						Union[str, Any]  ,					_A		:						Dict=-2      )  ->			List[str]:
   __magic_name__	:   Dict					     =					deque()
   __magic_name__	:   List[Any]					     =					[]
   if s == -2:
    __magic_name__	:   Union[str, Any]					     =					list(self.graph      )[0]
   d.append(_A      )
   visited.append(_A      )
   while d:
    __magic_name__	:   Optional[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        __lowerCAmelCase		( self		:						Union[str, Any]  ,					_A		:						Optional[Any]      )  ->			List[Any]:
   return len(self.graph[u]      )







  def        __lowerCAmelCase		( self		:						Union[str, Any]      )  ->			Union[str, Any]:
   __magic_name__	:   Dict					     =					[]
   __magic_name__	:   List[Any]					     =					[]
   __magic_name__	:   Union[str, Any]					     =					list(self.graph      )[0]
   stack.append(_A      )
   visited.append(_A      )
   __magic_name__	:   Optional[Any]					     =					-2
   __magic_name__	:   Union[str, Any]					     =					[]
   __magic_name__	:   str					     =					s
   __magic_name__	:   Optional[Any]					     =					False
   __magic_name__	:   Dict					     =					set()

   while True:
    # check if there is any non isolated nodes
    if len(self.graph[s]      ) != 0:
     __magic_name__	:   Optional[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
      ):
       __magic_name__	:   Tuple					     =					len(_A      ) - 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]      )
       __magic_name__	:   Optional[Any]					     =					node[1]
       break

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

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







  def        __lowerCAmelCase		( self		:						List[str]      )  ->			str:
   __magic_name__	:   Tuple					     =					[]
   __magic_name__	:   Any					     =					[]
   __magic_name__	:   Dict					     =					list(self.graph      )[0]
   stack.append(_A      )
   visited.append(_A      )
   __magic_name__	:   Tuple					     =					-2
   __magic_name__	:   Union[str, Any]					     =					[]
   __magic_name__	:   Any					     =					s
   __magic_name__	:   Any					     =					False
   __magic_name__	:   Union[str, Any]					     =					set()

   while True:
    # check if there is any non isolated nodes
    if len(self.graph[s]      ) != 0:
     __magic_name__	:   Optional[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
      ):
       __magic_name__	:   Tuple					     =					len(_A      ) - 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]      )
       __magic_name__	:   List[str]					     =					node[1]
       break

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

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







  def        __lowerCAmelCase		( self		:						Any      )  ->			int:
   return list(self.graph      )







  def        __lowerCAmelCase		( self		:						List[str]  ,					_A		:						List[str]=-2  ,					_A		:						List[Any]=-1      )  ->			Tuple:
   __magic_name__	:   Tuple					     =					time()
   self.dfs(_A  ,					_A      )
   __magic_name__	:   Optional[int]					     =					time()
   return end - begin







  def        __lowerCAmelCase		( self		:						Any  ,					_A		:						List[str]=-2      )  ->			Optional[Any]:
   __magic_name__	:   Any					     =					time()
   self.bfs(_A      )
   __magic_name__	:   str					     =					time()
   return end - begin



'''simple docstring'''

lowerCAmelCase				:Union[str, Any]        =      '''
# Transformers installation
! pip install transformers datasets
# To install from source instead of the last release, comment the command above and uncomment the following one.
# ! pip install git+https://github.com/huggingface/transformers.git
'''

lowerCAmelCase				:Union[str, Any]        =      [{'''type''': '''code''', '''content''': INSTALL_CONTENT}]
lowerCAmelCase				:Tuple        =      {
    '''{processor_class}''': '''FakeProcessorClass''',
    '''{model_class}''': '''FakeModelClass''',
    '''{object_class}''': '''FakeObjectClass''',
}