


import sys
from collections import defaultdict




class    UpperCAmelCase					:




			def __init__(						self							:		Optional[int]						):







						"""simple docstring"""







						UpperCamelCase         =					[]




			def   lowerCamelCase_					(						self							:		Tuple       ,       __magic_name__							:		Union[str, Any]						):







						"""simple docstring"""







						return self.node_position[vertex]




			def   lowerCamelCase_					(						self							:		Optional[Any]       ,       __magic_name__							:		str       ,       __magic_name__							:		Any						):







						"""simple docstring"""







						UpperCamelCase         =					pos




			def   lowerCamelCase_					(						self							:		Union[str, Any]       ,       __magic_name__							:		int       ,       __magic_name__							:		int       ,       __magic_name__							:		int       ,       __magic_name__							:		Optional[Any]						):







						"""simple docstring"""







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

												UpperCamelCase         =					self.get_position(positions[smallest_child]						)
												self.set_position(
												    positions[smallest_child]       ,       self.get_position(positions[start]						)						)
												self.set_position(positions[start]       ,       __magic_name__						)

												self.top_to_bottom(__magic_name__       ,       __magic_name__       ,       __magic_name__       ,       __magic_name__						)




			def   lowerCamelCase_					(						self							:		Any       ,       __magic_name__							:		Tuple       ,       __magic_name__							:		str       ,       __magic_name__							:		Dict       ,       __magic_name__							:		Dict						):







						"""simple docstring"""







						UpperCamelCase         =					position[index]

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

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




			def   lowerCamelCase_					(						self							:		Any       ,       __magic_name__							:		Optional[int]       ,       __magic_name__							:		Optional[Any]						):







						"""simple docstring"""







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





			def   lowerCamelCase_					(						self							:		str       ,       __magic_name__							:		Tuple       ,       __magic_name__							:		int						):







						"""simple docstring"""







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






def 							_lowercase    (		SCREAMING_SNAKE_CASE_   :		Tuple	):





			"""simple docstring"""




			UpperCamelCase         =					Heap()

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

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

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

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


if __name__ == "__main__":  # pragma: no cover
							# < --------- Prims Algorithm --------- >
							__snake_case            =   int(input("Enter number of edges: ").strip())
							__snake_case            =   defaultdict(list)
							for _ in range(edges_number):
														__snake_case            =   [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))








import torch

from transformers import AutoModel




class    UpperCAmelCase					(       torch.nn.Module    ):




			def __init__(						self							:		int       ,       __magic_name__							:		List[Any]="sayef/fsner-bert-base-uncased"						):







						"""simple docstring"""







						super(__magic_name__       ,       self						).__init__()

						UpperCamelCase         =					AutoModel.from_pretrained(__magic_name__       ,       return_dict=__magic_name__						)
						UpperCamelCase         =					torch.nn.CosineSimilarity(3       ,       1e-08						)
						UpperCamelCase         =					torch.nn.Softmax(dim=1						)




			def   lowerCamelCase_					(						self							:		Optional[int]       ,       **__magic_name__							:		List[Any]						):







						"""simple docstring"""







						return self.bert(**__magic_name__						).last_hidden_state




			def   lowerCamelCase_					(						self							:		Tuple       ,       __magic_name__							:		int						):







						"""simple docstring"""







						return token_embeddings.sum(2       ,       keepdim=__magic_name__						)




			def   lowerCamelCase_					(						self							:		Optional[Any]       ,       __magic_name__							:		List[str]       ,       __magic_name__							:		Union[str, Any]       ,       __magic_name__							:		Optional[Any]=1						):







						"""simple docstring"""







						return self.softmax(T * self.cos(__magic_name__       ,       __magic_name__						)						)





			def   lowerCamelCase_					(						self							:		Union[str, Any]       ,       __magic_name__							:		List[Any]       ,       __magic_name__							:		List[str]						):







						"""simple docstring"""







						UpperCamelCase         =					W_supports["""sizes"""].tolist()
						UpperCamelCase         =					W_supports["""start_token_id"""].item()
						UpperCamelCase         =					W_supports["""end_token_id"""].item()

						del W_supports["sizes"]
						del W_supports["start_token_id"]
						del W_supports["end_token_id"]

						UpperCamelCase         =					self.BERT(**__magic_name__						)
						UpperCamelCase         =					self.BERT(**__magic_name__						)

						UpperCamelCase         =					None
						UpperCamelCase         =					None

						UpperCamelCase         =					W_supports["""input_ids"""] == start_token_id
						UpperCamelCase         =					W_supports["""input_ids"""] == end_token_id

						for i, size in enumerate(__magic_name__						):
									if i == 0:
												UpperCamelCase         =					0
									else:
												UpperCamelCase         =					support_sizes[i - 1]

									UpperCamelCase         =					S[s : s + size][start_token_masks[s : s + size]]
									UpperCamelCase         =					S[s : s + size][end_token_masks[s : s + size]]

									UpperCamelCase         =					torch.matmul(q[i]       ,       s_start.T						).sum(1						).softmax(0						)
									UpperCamelCase         =					torch.matmul(q[i]       ,       s_end.T						).sum(1						).softmax(0						)

									if p_starts is not None:
												UpperCamelCase         =					torch.vstack((p_starts, p_start)						)
												UpperCamelCase         =					torch.vstack((p_ends, p_end)						)
									else:
												UpperCamelCase         =					p_start
												UpperCamelCase         =					p_end

						return p_starts, p_ends




