




import sys
from collections import defaultdict




class 		__A   :

						def __init__(		self :Any			):
										'''simple docstring'''

										__magic_name__						:						List[Any]										=[]

						def      A__    (		self :int     ,			__snake_case :Optional[int]			):
										'''simple docstring'''

										return self.node_position[vertex]

						def      A__    (		self :Optional[int]     ,			__snake_case :int     ,			__snake_case :Dict			):
										'''simple docstring'''

										__magic_name__						:						Union[str, Any]										=pos

						def      A__    (		self :Optional[Any]     ,			__snake_case :int     ,			__snake_case :List[str]     ,			__snake_case :Dict     ,			__snake_case :List[Any]			):
										'''simple docstring'''

										if start > size // 2 - 1:
														return
										else:
														if 2 * start + 2 >= size:
																		__magic_name__						:						Optional[int]										=2 * start + 1
														else:
																		if heap[2 * start + 1] < heap[2 * start + 2]:
																						__magic_name__						:						Optional[Any]										=2 * start + 1
																		else:
																						__magic_name__						:						Tuple										=2 * start + 2
														if heap[smallest_child] < heap[start]:
																		__magic_name__					,			__magic_name__						:						str										=heap[smallest_child], positions[smallest_child]
																		__magic_name__					,			__magic_name__						:						int										=(
																		    heap[start],
																		    positions[start],
																		)
																		__magic_name__					,			__magic_name__						:						List[Any]										=temp, tempa

																		__magic_name__						:						Tuple										=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      A__    (		self :Optional[Any]     ,			__snake_case :Optional[int]     ,			__snake_case :Optional[int]     ,			__snake_case :int     ,			__snake_case :List[str]			):
										'''simple docstring'''

										__magic_name__						:						Dict										=position[index]

										while index != 0:
														__magic_name__						:						List[str]										=int((index - 2) / 2			) if index % 2 == 0 else int((index - 1) / 2			)

														if val < heap[parent]:
																		__magic_name__						:						List[Any]										=heap[parent]
																		__magic_name__						:						Dict										=position[parent]
																		self.set_position(position[parent]     ,			__lowerCamelCase			)
														else:
																		__magic_name__						:						Optional[Any]										=val
																		__magic_name__						:						Optional[Any]										=temp
																		self.set_position(__lowerCamelCase     ,			__lowerCamelCase			)
																		break
														__magic_name__						:						str										=parent
										else:
														__magic_name__						:						Tuple										=val
														__magic_name__						:						str										=temp
														self.set_position(__lowerCamelCase     ,			0			)

						def      A__    (		self :Optional[Any]     ,			__snake_case :Optional[int]     ,			__snake_case :str			):
										'''simple docstring'''

										__magic_name__						:						List[str]										=len(__lowerCamelCase			) // 2 - 1
										for i in range(__lowerCamelCase     ,			-1     ,			-1			):
														self.top_to_bottom(__lowerCamelCase     ,			__lowerCamelCase     ,			len(__lowerCamelCase			)     ,			__lowerCamelCase			)


						def      A__    (		self :Union[str, Any]     ,			__snake_case :Optional[int]     ,			__snake_case :Union[str, Any]			):
										'''simple docstring'''

										__magic_name__						:						Optional[int]										=positions[0]
										__magic_name__						:						List[str]										=sys.maxsize
										self.top_to_bottom(__lowerCamelCase     ,			0     ,			len(__lowerCamelCase			)     ,			__lowerCamelCase			)
										return temp




def 		lowerCAmelCase_ (						lowerCamelCase ):
				__magic_name__						:						Union[str, Any]										=Heap()

				__magic_name__						:						int										=[0] * len(lowerCamelCase )
				__magic_name__						:						Union[str, Any]										=[-1] * len(lowerCamelCase )  # Neighboring Tree Vertex of selected vertex
				# Minimum Distance of explored vertex with neighboring vertex of partial tree
				# formed in graph
				__magic_name__						:						Any										=[]  # Heap of Distance of vertices from their neighboring vertex
				__magic_name__						:						Any										=[]

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

				__magic_name__						:						Optional[Any]										=[]
				__magic_name__						:						Dict										=1
				__magic_name__						:						Tuple										=sys.maxsize
				for neighbor, distance in adjacency_list[0]:
								__magic_name__						:						Dict										=0
								__magic_name__						:						Dict										=distance
				heap.heapify(lowerCamelCase						,  lowerCamelCase )

				for _ in range(1						,  len(lowerCamelCase ) ):
								__magic_name__						:						List[Any]										=heap.delete_minimum(lowerCamelCase						,  lowerCamelCase )
								if visited[vertex] == 0:
												tree_edges.append((nbr_tv[vertex], vertex) )
												__magic_name__						:						List[Any]										=1
												for neighbor, distance in adjacency_list[vertex]:
																if (
																    visited[neighbor] == 0
																    and distance < distance_tv[heap.get_position(lowerCamelCase )]
																):
																				__magic_name__						:						int										=distance
																				heap.bottom_to_top(
																				    lowerCamelCase						,  heap.get_position(lowerCamelCase )						,  lowerCamelCase						,  lowerCamelCase )
																				__magic_name__						:						Union[str, Any]										=vertex
				return tree_edges


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











def  SCREAMING_SNAKE_CASE				(      snake_case						,   snake_case							)		->    bool:
		__lowercase											=     len(snake_case							) + 1
		__lowercase											=     len(snake_case							) + 1

		# dp is a 2d matrix where dp[i][j] denotes whether prefix string of
		# length i of input_string matches with prefix string of length j of
		# given pattern.
		# "dp" stands for dynamic programming.
		__lowercase											=     [[0 for i in range(snake_case							)] for j in range(snake_case							)]

		# since string of zero length match pattern of zero length
		__lowercase											=     1

		# since pattern of zero length will never match with string of non-zero length
		for i in range(1						,   snake_case							):
				__lowercase											=     0

		# since string of zero length will match with pattern where there
		# is at least one * alternatively
		for j in range(1						,   snake_case							):
				__lowercase											=     dp[0][j - 2] if pattern[j - 1] == '*' else 0

		# now using bottom-up approach to find for all remaining lengths
		for i in range(1						,   snake_case							):
				for j in range(1						,   snake_case							):
						if input_string[i - 1] == pattern[j - 1] or pattern[j - 1] == ".":
								__lowercase											=     dp[i - 1][j - 1]

						elif pattern[j - 1] == "*":
								if dp[i][j - 2] == 1:
										__lowercase											=     1
								elif pattern[j - 2] in (input_string[i - 1], "."):
										__lowercase											=     dp[i - 1][j]
								else:
										__lowercase											=     0
						else:
								__lowercase											=     0

		return bool(dp[-1][-1]							)


if __name__ == "__main__":
		import doctest

		doctest.testmod()
		# inputing the strings
		# input_string = input("input a string :")
		# pattern = input("input a pattern :")

		SCREAMING_SNAKE_CASE_   :      Any			=   '''aab'''
		SCREAMING_SNAKE_CASE_   :      str			=   '''c*a*b'''

		# using function to check whether given string matches the given pattern
		if match_pattern(input_string, pattern):
				print(F"""{input_string} matches the given pattern {pattern}""")
		else:
				print(F"""{input_string} does not match with the given pattern {pattern}""")




