


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

class 						A__							:




						def __init__(       self					:      Any  )							->     List[Any]:


										"""simple docstring"""





										_SCREAMING_SNAKE_CASE			  ={}




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


										"""simple docstring"""





										if self.graph.get(_a  ):
														if self.graph[u].count([w, v]  ) == 0:
																		self.graph[u].append([w, v]  )
										else:
														_SCREAMING_SNAKE_CASE			  =[[w, v]]
										if not self.graph.get(_a  ):
														_SCREAMING_SNAKE_CASE			  =[]




						def 							__UpperCamelCase				(       self					:      Any  )							->     List[str]:


										"""simple docstring"""





										return list(self.graph  )




						def 							__UpperCamelCase				(       self					:      Optional[int]				,    _a					:      Union[str, Any]				,    _a					:      List[str]  )							->     Any:


										"""simple docstring"""





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




						def 							__UpperCamelCase				(       self					:      Dict				,    _a					:      List[str]=-2				,    _a					:      int=-1  )							->     str:


										"""simple docstring"""





										if s == d:
														return []
										_SCREAMING_SNAKE_CASE			  =[]
										_SCREAMING_SNAKE_CASE			  =[]
										if s == -2:
														_SCREAMING_SNAKE_CASE			  =list(self.graph  )[0]
										stack.append(_a  )
										visited.append(_a  )
										_SCREAMING_SNAKE_CASE			  =s

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

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

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




						def 							__UpperCamelCase				(       self					:      Dict				,    _a					:      List[str]=-1  )							->     Optional[int]:


										"""simple docstring"""





										if c == -1:
														_SCREAMING_SNAKE_CASE			  =floor(random() * 1_0000  ) + 10
										for i in range(_a  ):
														# every vertex has max 100 edges
														for _ in range(floor(random() * 102  ) + 1  ):
																		_SCREAMING_SNAKE_CASE			  =floor(random() * c  ) + 1
																		if n != i:
																						self.add_pair(_a				,    _a				,    1  )




						def 							__UpperCamelCase				(       self					:      Union[str, Any]				,    _a					:      int=-2  )							->     Optional[int]:


										"""simple docstring"""





										_SCREAMING_SNAKE_CASE			  =deque()
										_SCREAMING_SNAKE_CASE			  =[]
										if s == -2:
														_SCREAMING_SNAKE_CASE			  =list(self.graph  )[0]
										d.append(_a  )
										visited.append(_a  )
										while d:
														_SCREAMING_SNAKE_CASE			  =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 							__UpperCamelCase				(       self					:      int				,    _a					:      Optional[Any]  )							->     Tuple:


										"""simple docstring"""





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




						def 							__UpperCamelCase				(       self					:      Any				,    _a					:      Tuple  )							->     Union[str, Any]:


										"""simple docstring"""





										return len(self.graph[u]  )




						def 							__UpperCamelCase				(       self					:      int				,    _a					:      Optional[int]=-2  )							->     Any:


										"""simple docstring"""





										_SCREAMING_SNAKE_CASE			  =[]
										_SCREAMING_SNAKE_CASE			  =[]
										if s == -2:
														_SCREAMING_SNAKE_CASE			  =list(self.graph  )[0]
										stack.append(_a  )
										visited.append(_a  )
										_SCREAMING_SNAKE_CASE			  =s
										_SCREAMING_SNAKE_CASE			  =[]

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

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

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




						def 							__UpperCamelCase				(       self					:      Union[str, Any]  )							->     Dict:


										"""simple docstring"""





										_SCREAMING_SNAKE_CASE			  =[]
										_SCREAMING_SNAKE_CASE			  =[]
										_SCREAMING_SNAKE_CASE			  =list(self.graph  )[0]
										stack.append(_a  )
										visited.append(_a  )
										_SCREAMING_SNAKE_CASE			  =-2
										_SCREAMING_SNAKE_CASE			  =[]
										_SCREAMING_SNAKE_CASE			  =s
										_SCREAMING_SNAKE_CASE			  =False
										_SCREAMING_SNAKE_CASE			  =set()

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

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

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




						def 							__UpperCamelCase				(       self					:      str  )							->     Optional[int]:


										"""simple docstring"""





										_SCREAMING_SNAKE_CASE			  =[]
										_SCREAMING_SNAKE_CASE			  =[]
										_SCREAMING_SNAKE_CASE			  =list(self.graph  )[0]
										stack.append(_a  )
										visited.append(_a  )
										_SCREAMING_SNAKE_CASE			  =-2
										_SCREAMING_SNAKE_CASE			  =[]
										_SCREAMING_SNAKE_CASE			  =s
										_SCREAMING_SNAKE_CASE			  =False
										_SCREAMING_SNAKE_CASE			  =set()

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

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

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




						def 							__UpperCamelCase				(       self					:      List[str]				,    _a					:      Any=-2				,    _a					:      Optional[int]=-1  )							->     Any:


										"""simple docstring"""





										_SCREAMING_SNAKE_CASE			  =time()
										self.dfs(_a				,    _a  )
										_SCREAMING_SNAKE_CASE			  =time()
										return end - begin




						def 							__UpperCamelCase				(       self					:      Any				,    _a					:      Optional[int]=-2  )							->     Dict:


										"""simple docstring"""





										_SCREAMING_SNAKE_CASE			  =time()
										self.bfs(_a  )
										_SCREAMING_SNAKE_CASE			  =time()
										return end - begin

class 						A__							:




						def __init__(       self					:      Dict  )							->     List[str]:


										"""simple docstring"""





										_SCREAMING_SNAKE_CASE			  ={}




						def 							__UpperCamelCase				(       self					:      Tuple				,    _a					:      Optional[int]				,    _a					:      Dict				,    _a					:      Dict=1  )							->     Dict:


										"""simple docstring"""





										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
														_SCREAMING_SNAKE_CASE			  =[[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
														_SCREAMING_SNAKE_CASE			  =[[w, u]]




						def 							__UpperCamelCase				(       self					:      Tuple				,    _a					:      Dict				,    _a					:      Optional[int]  )							->     Dict:


										"""simple docstring"""





										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 							__UpperCamelCase				(       self					:      Optional[int]				,    _a					:      Dict=-2				,    _a					:      int=-1  )							->     int:


										"""simple docstring"""





										if s == d:
														return []
										_SCREAMING_SNAKE_CASE			  =[]
										_SCREAMING_SNAKE_CASE			  =[]
										if s == -2:
														_SCREAMING_SNAKE_CASE			  =list(self.graph  )[0]
										stack.append(_a  )
										visited.append(_a  )
										_SCREAMING_SNAKE_CASE			  =s

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

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

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




						def 							__UpperCamelCase				(       self					:      Union[str, Any]				,    _a					:      List[str]=-1  )							->     List[Any]:


										"""simple docstring"""





										if c == -1:
														_SCREAMING_SNAKE_CASE			  =floor(random() * 1_0000  ) + 10
										for i in range(_a  ):
														# every vertex has max 100 edges
														for _ in range(floor(random() * 102  ) + 1  ):
																		_SCREAMING_SNAKE_CASE			  =floor(random() * c  ) + 1
																		if n != i:
																						self.add_pair(_a				,    _a				,    1  )




						def 							__UpperCamelCase				(       self					:      List[Any]				,    _a					:      int=-2  )							->     Dict:


										"""simple docstring"""





										_SCREAMING_SNAKE_CASE			  =deque()
										_SCREAMING_SNAKE_CASE			  =[]
										if s == -2:
														_SCREAMING_SNAKE_CASE			  =list(self.graph  )[0]
										d.append(_a  )
										visited.append(_a  )
										while d:
														_SCREAMING_SNAKE_CASE			  =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 							__UpperCamelCase				(       self					:      List[str]				,    _a					:      Union[str, Any]  )							->     List[Any]:


										"""simple docstring"""





										return len(self.graph[u]  )




						def 							__UpperCamelCase				(       self					:      int  )							->     str:


										"""simple docstring"""





										_SCREAMING_SNAKE_CASE			  =[]
										_SCREAMING_SNAKE_CASE			  =[]
										_SCREAMING_SNAKE_CASE			  =list(self.graph  )[0]
										stack.append(_a  )
										visited.append(_a  )
										_SCREAMING_SNAKE_CASE			  =-2
										_SCREAMING_SNAKE_CASE			  =[]
										_SCREAMING_SNAKE_CASE			  =s
										_SCREAMING_SNAKE_CASE			  =False
										_SCREAMING_SNAKE_CASE			  =set()

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

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

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




						def 							__UpperCamelCase				(       self					:      List[Any]  )							->     Optional[int]:


										"""simple docstring"""





										_SCREAMING_SNAKE_CASE			  =[]
										_SCREAMING_SNAKE_CASE			  =[]
										_SCREAMING_SNAKE_CASE			  =list(self.graph  )[0]
										stack.append(_a  )
										visited.append(_a  )
										_SCREAMING_SNAKE_CASE			  =-2
										_SCREAMING_SNAKE_CASE			  =[]
										_SCREAMING_SNAKE_CASE			  =s
										_SCREAMING_SNAKE_CASE			  =False
										_SCREAMING_SNAKE_CASE			  =set()

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

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

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




						def 							__UpperCamelCase				(       self					:      Any  )							->     Dict:


										"""simple docstring"""





										return list(self.graph  )




						def 							__UpperCamelCase				(       self					:      int				,    _a					:      str=-2				,    _a					:      int=-1  )							->     Optional[int]:


										"""simple docstring"""





										_SCREAMING_SNAKE_CASE			  =time()
										self.dfs(_a				,    _a  )
										_SCREAMING_SNAKE_CASE			  =time()
										return end - begin




						def 							__UpperCamelCase				(       self					:      Optional[int]				,    _a					:      Any=-2  )							->     int:


										"""simple docstring"""





										_SCREAMING_SNAKE_CASE			  =time()
										self.bfs(_a  )
										_SCREAMING_SNAKE_CASE			  =time()
										return end - begin



from typing import TYPE_CHECKING

from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_speech_available, is_torch_available


snake_case_						:			Optional[Any]													=							{
    '''configuration_audio_spectrogram_transformer''': [
        '''AUDIO_SPECTROGRAM_TRANSFORMER_PRETRAINED_CONFIG_ARCHIVE_MAP''',
        '''ASTConfig''',
    ]
}

try:
							if not is_torch_available():
														raise OptionalDependencyNotAvailable()
except OptionalDependencyNotAvailable:
							pass
else:
							snake_case_						:			Optional[Any]													=							[
							    '''AUDIO_SPECTROGRAM_TRANSFORMER_PRETRAINED_MODEL_ARCHIVE_LIST''',
							    '''ASTForAudioClassification''',
							    '''ASTModel''',
							    '''ASTPreTrainedModel''',
							]

try:
							if not is_speech_available():
														raise OptionalDependencyNotAvailable()
except OptionalDependencyNotAvailable:
							pass
else:
							snake_case_						:			List[Any]													=							['''ASTFeatureExtractor''']

if TYPE_CHECKING:
							from .configuration_audio_spectrogram_transformer import (
							    AUDIO_SPECTROGRAM_TRANSFORMER_PRETRAINED_CONFIG_ARCHIVE_MAP,
							    ASTConfig,
							)

							try:
														if not is_torch_available():
																					raise OptionalDependencyNotAvailable()
							except OptionalDependencyNotAvailable:
														pass
							else:
														from .modeling_audio_spectrogram_transformer import (
														    AUDIO_SPECTROGRAM_TRANSFORMER_PRETRAINED_MODEL_ARCHIVE_LIST,
														    ASTForAudioClassification,
														    ASTModel,
														    ASTPreTrainedModel,
														)

							try:
														if not is_speech_available():
																					raise OptionalDependencyNotAvailable()
							except OptionalDependencyNotAvailable:
														pass
							else:
														from .feature_extraction_audio_spectrogram_transformer import ASTFeatureExtractor


else:
							import sys

							snake_case_						:			Optional[Any]													=							_LazyModule(__name__, globals()['''__file__'''], _import_structure, module_spec=__spec__)