

import sys
from collections import defaultdict

class       a		:







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







								__lowerCAmelCase         =							[]







							def       UpperCAmelCase__					(						self  :  List[Any]      ,				snake_case__  :  Tuple ):
								"""simple docstring"""







								return self.node_position[vertex]







							def       UpperCAmelCase__					(						self  :  Union[str, Any]      ,				snake_case__  :  List[Any]      ,				snake_case__  :  Optional[Any] ):
								"""simple docstring"""







								__lowerCAmelCase         =							pos







							def       UpperCAmelCase__					(						self  :  Optional[int]      ,				snake_case__  :  Any      ,				snake_case__  :  Optional[Any]      ,				snake_case__  :  Any      ,				snake_case__  :  Optional[Any] ):
								"""simple docstring"""







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

										__lowerCAmelCase         =							self.get_position(positions[smallest_child] )
										self.set_position(
										    positions[smallest_child]      ,				self.get_position(positions[start] ) )
										self.set_position(positions[start]      ,				snake_case__ )

										self.top_to_bottom(snake_case__      ,				snake_case__      ,				snake_case__      ,				snake_case__ )







							def       UpperCAmelCase__					(						self  :  Tuple      ,				snake_case__  :  Optional[int]      ,				snake_case__  :  Any      ,				snake_case__  :  Union[str, Any]      ,				snake_case__  :  List[str] ):
								"""simple docstring"""







								__lowerCAmelCase         =							position[index]

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

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







							def       UpperCAmelCase__					(						self  :  List[Any]      ,				snake_case__  :  Union[str, Any]      ,				snake_case__  :  List[str] ):
								"""simple docstring"""







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







							def       UpperCAmelCase__					(						self  :  Optional[Any]      ,				snake_case__  :  Optional[int]      ,				snake_case__  :  Tuple ):
								"""simple docstring"""







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






def 		_UpperCAmelCase   (	UpperCamelCase:     List[str]  ):






	"""simple docstring"""


	__lowerCAmelCase         =							Heap()

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

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

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

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


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






def 		_UpperCAmelCase   (	UpperCamelCase:     str  ):






	"""simple docstring"""


	__lowerCAmelCase         =							""
	try:
		with open(UpperCamelCase			,							"rb"  ) as binary_file:
			__lowerCAmelCase         =							binary_file.read()
		for dat in data:
			__lowerCAmelCase         =							F"{dat:08b}"
			result += curr_byte
		return result
	except OSError:
		print("File not accessible"  )
		sys.exit()






def 		_UpperCAmelCase   (	UpperCamelCase:     str  ):






	"""simple docstring"""


	__lowerCAmelCase         =							{"0": "0", "1": "1"}
	__lowerCAmelCase   ,						__lowerCAmelCase         =							"", ""
	__lowerCAmelCase         =							len(UpperCamelCase  )

	for i in range(len(UpperCamelCase  )  ):
		curr_string += data_bits[i]
		if curr_string not in lexicon:
			continue

		__lowerCAmelCase         =							lexicon[curr_string]
		result += last_match_id
		__lowerCAmelCase         =							last_match_id + "0"

		if math.loga(UpperCamelCase  ).is_integer():
			__lowerCAmelCase         =							{}
			for curr_key in list(UpperCamelCase  ):
				__lowerCAmelCase         =							lexicon.pop(UpperCamelCase  )
			__lowerCAmelCase         =							new_lex

		__lowerCAmelCase         =							last_match_id + "1"
		index += 1
		__lowerCAmelCase         =							""
	return result






def 		_UpperCAmelCase   (	UpperCamelCase:     str			,							UpperCamelCase:     str  ):






	"""simple docstring"""


	__lowerCAmelCase         =							8
	try:
		with open(UpperCamelCase			,							"wb"  ) as opened_file:
			__lowerCAmelCase         =							[
			    to_write[i : i + byte_length]
			    for i in range(0			,							len(UpperCamelCase  )			,							UpperCamelCase  )
			]

			if len(result_byte_array[-1]  ) % byte_length == 0:
				result_byte_array.append("10000000"  )
			else:
				result_byte_array[-1] += "1" + "0" * (
				    byte_length - len(result_byte_array[-1]  ) - 1
				)

			for elem in result_byte_array[:-1]:
				opened_file.write(int(UpperCamelCase			,							2  ).to_bytes(1			,							byteorder="big"  )  )
	except OSError:
		print("File not accessible"  )
		sys.exit()






def 		_UpperCAmelCase   (	UpperCamelCase:     str  ):






	"""simple docstring"""


	__lowerCAmelCase         =							0
	for letter in data_bits:
		if letter == "1":
			break
		counter += 1

	__lowerCAmelCase         =							data_bits[counter:]
	__lowerCAmelCase         =							data_bits[counter + 1 :]
	return data_bits






def 		_UpperCAmelCase   (	UpperCamelCase:     str			,							UpperCamelCase:     str  ):






	"""simple docstring"""


	__lowerCAmelCase         =							read_file_binary(UpperCamelCase  )
	__lowerCAmelCase         =							remove_prefix(UpperCamelCase  )
	__lowerCAmelCase         =							decompress_data(UpperCamelCase  )
	write_file_binary(UpperCamelCase			,							UpperCamelCase  )


if __name__ == "__main__":
					compress(sys.argv[1], sys.argv[2])






