




'''simple docstring'''


from collections import OrderedDict
from typing import TYPE_CHECKING, Any, Mapping, Optional

from packaging import version

from ...configuration_utils import PretrainedConfig
from ...onnx import OnnxConfig
from ...onnx.utils import compute_effective_axis_dimension
from ...utils import logging


if TYPE_CHECKING:
				from ...processing_utils import ProcessorMixin
				from ...utils import TensorType


_snake_case   :   int     							=	logging.get_logger(__name__)

_snake_case   :   Optional[int]     							=	{
    "microsoft/layoutlmv3-base": "https://huggingface.co/microsoft/layoutlmv3-base/resolve/main/config.json",
}

class        A					(	_a					):
							lowercase_           =       'layoutlmv3'







							def __init__(						self :						Union[str, Any]							,    lowerCAmelCase_ :						Tuple=5_02_65							,    lowerCAmelCase_ :						Union[str, Any]=7_68							,    lowerCAmelCase_ :						List[Any]=12							,    lowerCAmelCase_ :						Union[str, Any]=12							,    lowerCAmelCase_ :						Optional[Any]=30_72							,    lowerCAmelCase_ :						Optional[Any]="gelu"							,    lowerCAmelCase_ :						List[Any]=0.1							,    lowerCAmelCase_ :						Any=0.1							,    lowerCAmelCase_ :						Any=5_12							,    lowerCAmelCase_ :						int=2							,    lowerCAmelCase_ :						Dict=0.0_2							,    lowerCAmelCase_ :						List[str]=1e-5							,    lowerCAmelCase_ :						Any=1							,    lowerCAmelCase_ :						Tuple=0							,    lowerCAmelCase_ :						str=2							,    lowerCAmelCase_ :						List[str]=10_24							,    lowerCAmelCase_ :						str=1_28							,    lowerCAmelCase_ :						List[Any]=1_28							,    lowerCAmelCase_ :						str=True							,    lowerCAmelCase_ :						Union[str, Any]=32							,    lowerCAmelCase_ :						List[Any]=1_28							,    lowerCAmelCase_ :						str=64							,    lowerCAmelCase_ :						Optional[Any]=2_56							,    lowerCAmelCase_ :						Tuple=True							,    lowerCAmelCase_ :						Optional[Any]=True							,    lowerCAmelCase_ :						List[Any]=True							,    lowerCAmelCase_ :						Union[str, Any]=2_24							,    lowerCAmelCase_ :						Tuple=3							,    lowerCAmelCase_ :						Optional[Any]=16							,    lowerCAmelCase_ :						Union[str, Any]=None							,    **lowerCAmelCase_ :						Any							,    )    ->							Optional[Any]:


														"""simple docstring"""


														super().__init__(
														    vocab_size=UpperCAmelCase__							,    hidden_size=UpperCAmelCase__							,    num_hidden_layers=UpperCAmelCase__							,    num_attention_heads=UpperCAmelCase__							,    intermediate_size=UpperCAmelCase__							,    hidden_act=UpperCAmelCase__							,    hidden_dropout_prob=UpperCAmelCase__							,    attention_probs_dropout_prob=UpperCAmelCase__							,    max_position_embeddings=UpperCAmelCase__							,    type_vocab_size=UpperCAmelCase__							,    initializer_range=UpperCAmelCase__							,    layer_norm_eps=UpperCAmelCase__							,    pad_token_id=UpperCAmelCase__							,    bos_token_id=UpperCAmelCase__							,    eos_token_id=UpperCAmelCase__							,    **UpperCAmelCase__							,    )
														_a			  =       max_ad_position_embeddings
														_a			  =       coordinate_size
														_a			  =       shape_size
														_a			  =       has_relative_attention_bias
														_a			  =       rel_pos_bins
														_a			  =       max_rel_pos
														_a			  =       has_spatial_attention_bias
														_a			  =       rel_ad_pos_bins
														_a			  =       max_rel_ad_pos
														_a			  =       text_embed
														_a			  =       visual_embed
														_a			  =       input_size
														_a			  =       num_channels
														_a			  =       patch_size
														_a			  =       classifier_dropout



class        A					(	_a					):
							lowercase_           =       version.parse('1.12'					)







							@property
							def      __lowerCAmelCase    (						self :						Union[str, Any]      )    ->							Mapping[str, Mapping[int, str]]:


														"""simple docstring"""


														if self.task in ["question-answering", "sequence-classification"]:
																					return OrderedDict(
																					    [
																					        ('''input_ids''', {0: '''batch''', 1: '''sequence'''}),
																					        ('''attention_mask''', {0: '''batch''', 1: '''sequence'''}),
																					        ('''bbox''', {0: '''batch''', 1: '''sequence'''}),
																					        ('''pixel_values''', {0: '''batch''', 1: '''num_channels''', 2: '''height''', 3: '''width'''}),
																					    ]      )
														else:
																					return OrderedDict(
																					    [
																					        ('''input_ids''', {0: '''batch''', 1: '''sequence'''}),
																					        ('''bbox''', {0: '''batch''', 1: '''sequence'''}),
																					        ('''attention_mask''', {0: '''batch''', 1: '''sequence'''}),
																					        ('''pixel_values''', {0: '''batch''', 1: '''num_channels'''}),
																					    ]      )







							@property
							def      __lowerCAmelCase    (						self :						List[Any]      )    ->							float:


														"""simple docstring"""


														return 1e-5







							@property
							def      __lowerCAmelCase    (						self :						List[str]      )    ->							int:


														"""simple docstring"""


														return 12







							def      __lowerCAmelCase    (						self :						str							,    lowerCAmelCase_ :						"ProcessorMixin"							,    lowerCAmelCase_ :						int = -1							,    lowerCAmelCase_ :						int = -1							,    lowerCAmelCase_ :						bool = False							,    lowerCAmelCase_ :						Optional["TensorType"] = None							,    lowerCAmelCase_ :						int = 3							,    lowerCAmelCase_ :						int = 40							,    lowerCAmelCase_ :						int = 40							,    )    ->							Mapping[str, Any]:


														"""simple docstring"""


														setattr(processor.image_processor							,    '''apply_ocr'''							,    UpperCAmelCase__      )

														# If dynamic axis (-1) we forward with a fixed dimension of 2 samples to avoid optimizations made by ONNX
														_a			  =       compute_effective_axis_dimension(
														    UpperCAmelCase__							,    fixed_dimension=OnnxConfig.default_fixed_batch							,    num_token_to_add=0      )
														# If dynamic axis (-1) we forward with a fixed dimension of 8 tokens to avoid optimizations made by ONNX
														_a			  =       processor.tokenizer.num_special_tokens_to_add(UpperCAmelCase__      )
														_a			  =       compute_effective_axis_dimension(
														    UpperCAmelCase__							,    fixed_dimension=OnnxConfig.default_fixed_sequence							,    num_token_to_add=UpperCAmelCase__      )
														# Generate dummy inputs according to compute batch and sequence
														_a			  =       [[''' '''.join([processor.tokenizer.unk_token]      ) * seq_length]] * batch_size

														# Generate dummy bounding boxes
														_a			  =       [[[48, 84, 73, 1_28]]] * batch_size

														# If dynamic axis (-1) we forward with a fixed dimension of 2 samples to avoid optimizations made by ONNX
														# batch_size = compute_effective_axis_dimension(batch_size, fixed_dimension=OnnxConfig.default_fixed_batch)
														_a			  =       self._generate_dummy_images(UpperCAmelCase__							,    UpperCAmelCase__							,    UpperCAmelCase__							,    UpperCAmelCase__      )

														_a			  =       dict(
														    processor(
														        UpperCAmelCase__							,    text=UpperCAmelCase__							,    boxes=UpperCAmelCase__							,    return_tensors=UpperCAmelCase__							,    )      )

														return inputs







'''simple docstring'''


import sys
from collections import defaultdict

class     A					:







							def __init__(						self :						Optional[Any]      )    ->							Union[str, Any]:


														"""simple docstring"""


														_a			  =       []







							def      __lowerCAmelCase    (						self :						Union[str, Any]							,    lowerCAmelCase_ :						List[Any]      )    ->							int:


														"""simple docstring"""


														return self.node_position[vertex]







							def      __lowerCAmelCase    (						self :						List[Any]							,    lowerCAmelCase_ :						Optional[Any]							,    lowerCAmelCase_ :						Optional[Any]      )    ->							Tuple:


														"""simple docstring"""


														_a			  =       pos







							def      __lowerCAmelCase    (						self :						Dict							,    lowerCAmelCase_ :						str							,    lowerCAmelCase_ :						Any							,    lowerCAmelCase_ :						Dict							,    lowerCAmelCase_ :						int      )    ->							Any:


														"""simple docstring"""


														if start > size // 2 - 1:
																					return
														else:
																					if 2 * start + 2 >= size:
																												_a			  =       2 * start + 1
																					else:
																												if heap[2 * start + 1] < heap[2 * start + 2]:
																																			_a			  =       2 * start + 1
																												else:
																																			_a			  =       2 * start + 2
																					if heap[smallest_child] < heap[start]:
																												_a  ,							_a			  =       heap[smallest_child], positions[smallest_child]
																												_a  ,							_a			  =       (
																												    heap[start],
																												    positions[start],
																												)
																												_a  ,							_a			  =       temp, tempa

																												_a			  =       self.get_position(positions[smallest_child]      )
																												self.set_position(
																												    positions[smallest_child]							,    self.get_position(positions[start]      )      )
																												self.set_position(positions[start]							,    lowerCAmelCase_      )

																												self.top_to_bottom(lowerCAmelCase_							,    lowerCAmelCase_							,    lowerCAmelCase_							,    lowerCAmelCase_      )







							def      __lowerCAmelCase    (						self :						Optional[int]							,    lowerCAmelCase_ :						List[str]							,    lowerCAmelCase_ :						List[Any]							,    lowerCAmelCase_ :						Any							,    lowerCAmelCase_ :						Dict      )    ->							Any:


														"""simple docstring"""


														_a			  =       position[index]

														while index != 0:
																					_a			  =       int((index - 2) / 2      ) if index % 2 == 0 else int((index - 1) / 2      )

																					if val < heap[parent]:
																												_a			  =       heap[parent]
																												_a			  =       position[parent]
																												self.set_position(position[parent]							,    lowerCAmelCase_      )
																					else:
																												_a			  =       val
																												_a			  =       temp
																												self.set_position(lowerCAmelCase_							,    lowerCAmelCase_      )
																												break
																					_a			  =       parent
														else:
																					_a			  =       val
																					_a			  =       temp
																					self.set_position(lowerCAmelCase_							,    0      )







							def      __lowerCAmelCase    (						self :						Any							,    lowerCAmelCase_ :						List[Any]							,    lowerCAmelCase_ :						Optional[Any]      )    ->							Optional[int]:


														"""simple docstring"""


														_a			  =       len(lowerCAmelCase_      ) // 2 - 1
														for i in range(lowerCAmelCase_							,    -1							,    -1      ):
																					self.top_to_bottom(lowerCAmelCase_							,    lowerCAmelCase_							,    len(lowerCAmelCase_      )							,    lowerCAmelCase_      )







							def      __lowerCAmelCase    (						self :						str							,    lowerCAmelCase_ :						str							,    lowerCAmelCase_ :						int      )    ->							List[Any]:


														"""simple docstring"""


														_a			  =       positions[0]
														_a			  =       sys.maxsize
														self.top_to_bottom(lowerCAmelCase_							,    0							,    len(lowerCAmelCase_      )							,    lowerCAmelCase_      )
														return temp



def 	snake_case_					(UpperCamelCase :						Any   ):





							'''simple docstring'''


							_a			  =       Heap()

							_a			  =       [0] * len(UpperCamelCase   )
							_a			  =       [-1] * len(UpperCamelCase   )  # Neighboring Tree Vertex of selected vertex
							# Minimum Distance of explored vertex with neighboring vertex of partial tree
							# formed in graph
							_a			  =       []  # Heap of Distance of vertices from their neighboring vertex
							_a			  =       []

							for vertex in range(len(UpperCamelCase   )   ):
														distance_tv.append(sys.maxsize   )
														positions.append(UpperCamelCase   )
														heap.node_position.append(UpperCamelCase   )

							_a			  =       []
							_a			  =       1
							_a			  =       sys.maxsize
							for neighbor, distance in adjacency_list[0]:
														_a			  =       0
														_a			  =       distance
							heap.heapify(UpperCamelCase				,		UpperCamelCase   )

							for _ in range(1				,		len(UpperCamelCase   )   ):
														_a			  =       heap.delete_minimum(UpperCamelCase				,		UpperCamelCase   )
														if visited[vertex] == 0:
																					tree_edges.append((nbr_tv[vertex], vertex)   )
																					_a			  =       1
																					for neighbor, distance in adjacency_list[vertex]:
																												if (
																												    visited[neighbor] == 0
																												    and distance < distance_tv[heap.get_position(UpperCamelCase   )]
																												):
																																			_a			  =       distance
																																			heap.bottom_to_top(
																																			    UpperCamelCase				,		heap.get_position(UpperCamelCase   )				,		UpperCamelCase				,		UpperCamelCase   )
																																			_a			  =       vertex
							return tree_edges


if __name__ == "__main__":  # pragma: no cover
				# < --------- Prims Algorithm --------- >
				_snake_case   :   List[str]     							=	int(input('Enter number of edges: ').strip())
				_snake_case   :   Union[str, Any]     							=	defaultdict(list)
				for _ in range(edges_number):
								_snake_case   :   Tuple     							=	[int(x) for x in input().strip().split()]
								adjacency_list[edge[0]].append([edge[1], edge[2]])
								adjacency_list[edge[1]].append([edge[0], edge[2]])
				print(prisms_algorithm(adjacency_list))

