




'''simple docstring'''


import sys
from collections import defaultdict

class      A       :







							def __init__(    self			:    Dict   )     ->				Any:


														"""simple docstring"""


														_a      	=							[]







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


														"""simple docstring"""


														return self.node_position[vertex]







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


														"""simple docstring"""


														_a      	=							pos







							def   __lowerCAmelCase     (    self			:    List[Any]				,     lowerCAmelCase_			:    Union[str, Any]				,     lowerCAmelCase_			:    int				,     lowerCAmelCase_			:    List[str]				,     lowerCAmelCase_			:    int   )     ->				Union[str, 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			:    Dict				,     lowerCAmelCase_			:    Optional[int]				,     lowerCAmelCase_			:    Optional[Any]				,     lowerCAmelCase_			:    Tuple				,     lowerCAmelCase_			:    Any   )     ->				Tuple:


														"""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			:    str				,     lowerCAmelCase_			:    Optional[Any]				,     lowerCAmelCase_			:    int   )     ->				List[str]:


														"""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			:    Any				,     lowerCAmelCase_			:    Tuple				,     lowerCAmelCase_			:    str   )     ->				Union[str, Any]:


														"""simple docstring"""


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



def 						snake_case_       (UpperCamelCase			:    Union[str, 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 : Optional[Any]  				=						int(input('Enter number of edges: ').strip())
				_snake_case : List[str]  				=						defaultdict(list)
				for _ in range(edges_number):
								_snake_case : List[str]  				=						[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))








from collections import defaultdict


class        __magic_name__	:





     """simple docstring"""



     def __init__(				self							:int      ,   snake_case							:Dict      ,   snake_case							:Optional[Any]	):





        '''simple docstring'''




        A_       :					Optional[int]        =      total  # total no of tasks (N)

        # DP table will have a dimension of (2^M)*N
        # initially all values are set to -1
        A_       :					str        =      [
            [-1 for i in range(total + 1	)] for j in range(2 ** len(snake_case	)	)
        ]

        A_       :					Optional[int]        =      defaultdict(snake_case	)  # stores the list of persons for each task

        # final_mask is used to check if all persons are included by setting all bits
        # to 1
        A_       :					Dict        =      (1 << len(snake_case	)) - 1



     def     SCREAMING_SNAKE_CASE		(				self							:Union[str, Any]      ,   snake_case							:Union[str, Any]      ,   snake_case							:str	):





        '''simple docstring'''




        if mask == self.final_mask:
           return 1

        # if not everyone gets the task and no more tasks are available, return 0
        if task_no > self.total_tasks:
           return 0

        # if case already considered
        if self.dp[mask][task_no] != -1:
           return self.dp[mask][task_no]

        # Number of ways when we don't this task in the arrangement
        A_       :					Tuple        =      self.count_ways_until(snake_case      ,   task_no + 1	)

        # now assign the tasks one by one to all possible persons and recursively
        # assign for the remaining tasks.
        if task_no in self.task:
           for p in self.task[task_no]:
              # if p is already given a task
              if mask & (1 << p):
                 continue

              # assign this task to p and change the mask value. And recursively
              # assign tasks with the new mask value.
              total_ways_util += self.count_ways_until(mask | (1 << p)      ,   task_no + 1	)

        # save the value.
        A_       :					Any        =      total_ways_util

        return self.dp[mask][task_no]





     def     SCREAMING_SNAKE_CASE		(				self							:int      ,   snake_case							:List[str]	):





        '''simple docstring'''




        for i in range(len(snake_case	)	):
           for j in task_performed[i]:
              self.task[j].append(snake_case	)

        # call the function to fill the DP table, final answer is stored in dp[0][1]
        return self.count_ways_until(0      ,   1	)


if __name__ == "__main__":
 _lowerCAmelCase				:   Dict						       =						5  # total no of tasks (the value of N)

 # the list of tasks that can be done by M persons.
 _lowerCAmelCase				:   str						       =						[[1, 3, 4], [1, 2, 5], [3, 4]]
 print(
     AssignmentUsingBitmask(task_performed, total_tasks).count_no_of_ways(
         task_performed
     )
 )
