


import numpy


class 					lowerCAmelCase_ :




						def __init__(	self						:   Optional[int]   ,     __A						:   numpy.ndarray   ,     __A						:   numpy.ndarray						)      ->None:






									"""simple docstring"""






									a__ :Any						  =    input_array

									# Random initial weights are assigned where first argument is the
									# number of nodes in previous layer and second argument is the
									# number of nodes in the next layer.

									# Random initial weights are assigned.
									# self.input_array.shape[1] is used to represent number of nodes in input layer.
									# First hidden layer consists of 4 nodes.
									a__ :Optional[int]						  =    numpy.random.rand(
									    self.input_array.shape[1]   ,     4						)

									# Random initial values for the first hidden layer.
									# First hidden layer has 4 nodes.
									# Second hidden layer has 3 nodes.
									a__ :Dict						  =    numpy.random.rand(
									    4   ,     3						)

									# Random initial values for the second hidden layer.
									# Second hidden layer has 3 nodes.
									# Output layer has 1 node.
									a__ :Any						  =    numpy.random.rand(3   ,     1						)

									# Real output values provided.
									a__ :Optional[Any]						  =    output_array

									# Predicted output values by the neural network.
									# Predicted_output array initially consists of zeroes.
									a__ :Any						  =    numpy.zeros(output_array.shape						)




						def  _snake_case					(	self						:   Dict						)      ->numpy.ndarray:






									"""simple docstring"""






									a__ :Optional[Any]						  =    sigmoid(
									    numpy.dot(self.input_array   ,     self.input_layer_and_first_hidden_layer_weights						)						)

									# layer_between_first_hidden_layer_and_second_hidden_layer is the layer
									# connecting the first hidden set of nodes with the second hidden set of nodes.
									a__ :int						  =    sigmoid(
									    numpy.dot(
									        self.layer_between_input_and_first_hidden_layer   ,     self.first_hidden_layer_and_second_hidden_layer_weights   ,     )						)

									# layer_between_second_hidden_layer_and_output is the layer connecting
									# second hidden layer with the output node.
									a__ :Tuple						  =    sigmoid(
									    numpy.dot(
									        self.layer_between_first_hidden_layer_and_second_hidden_layer   ,     self.second_hidden_layer_and_output_layer_weights   ,     )						)

									return self.layer_between_second_hidden_layer_and_output




						def  _snake_case					(	self						:   Optional[int]						)      ->None:






									"""simple docstring"""






									a__ :List[str]						  =    numpy.dot(
									    self.layer_between_first_hidden_layer_and_second_hidden_layer.T   ,     2
									    * (self.output_array - self.predicted_output)
									    * sigmoid_derivative(self.predicted_output						)   ,     )
									a__ :List[str]						  =    numpy.dot(
									    self.layer_between_input_and_first_hidden_layer.T   ,     numpy.dot(
									        2
									        * (self.output_array - self.predicted_output)
									        * sigmoid_derivative(self.predicted_output						)   ,     self.second_hidden_layer_and_output_layer_weights.T   ,     )
									    * sigmoid_derivative(
									        self.layer_between_first_hidden_layer_and_second_hidden_layer						)   ,     )
									a__ :Union[str, Any]						  =    numpy.dot(
									    self.input_array.T   ,     numpy.dot(
									        numpy.dot(
									            2
									            * (self.output_array - self.predicted_output)
									            * sigmoid_derivative(self.predicted_output						)   ,     self.second_hidden_layer_and_output_layer_weights.T   ,     )
									        * sigmoid_derivative(
									            self.layer_between_first_hidden_layer_and_second_hidden_layer						)   ,     self.first_hidden_layer_and_second_hidden_layer_weights.T   ,     )
									    * sigmoid_derivative(self.layer_between_input_and_first_hidden_layer						)   ,     )

									self.input_layer_and_first_hidden_layer_weights += (
									    updated_input_layer_and_first_hidden_layer_weights
									)
									self.first_hidden_layer_and_second_hidden_layer_weights += (
									    updated_first_hidden_layer_and_second_hidden_layer_weights
									)
									self.second_hidden_layer_and_output_layer_weights += (
									    updated_second_hidden_layer_and_output_layer_weights
									)




						def  _snake_case					(	self						:   List[Any]   ,     __A						:   numpy.ndarray   ,     __A						:   int   ,     __A						:   bool						)      ->None:






									"""simple docstring"""






									for iteration in range(1   ,     iterations + 1						):
												a__ :str						  =    self.feedforward()
												self.back_propagation()
												if give_loss:
															a__ :int						  =    numpy.mean(numpy.square(output - self.feedforward()						)						)
															print(F'''Iteration {iteration} Loss: {loss}'''						)






						def  _snake_case					(	self						:   Optional[int]   ,     __A						:   numpy.ndarray						)      ->int:






									"""simple docstring"""






									a__ :List[Any]						  =    input_arr

									a__ :Tuple						  =    sigmoid(
									    numpy.dot(self.array   ,     self.input_layer_and_first_hidden_layer_weights						)						)

									a__ :str						  =    sigmoid(
									    numpy.dot(
									        self.layer_between_input_and_first_hidden_layer   ,     self.first_hidden_layer_and_second_hidden_layer_weights   ,     )						)

									a__ :Optional[int]						  =    sigmoid(
									    numpy.dot(
									        self.layer_between_first_hidden_layer_and_second_hidden_layer   ,     self.second_hidden_layer_and_output_layer_weights   ,     )						)

									return int(self.layer_between_second_hidden_layer_and_output > 0.6						)






def 				lowerCamelCase__	(      a	:   numpy.ndarray				)    ->	numpy.ndarray:





			"""simple docstring"""
			return 1 / (1 + numpy.exp(-value				))


def 				lowerCamelCase__	(      a	:   numpy.ndarray				)    ->	numpy.ndarray:





			"""simple docstring"""
			return (value) * (1 - (value))


def 				lowerCamelCase__	(      )    ->	int:





			"""simple docstring"""
			a__ :List[str]						  =    numpy.array(
			    (
			        [0, 0, 0],
			        [0, 0, 1],
			        [0, 1, 0],
			        [0, 1, 1],
			        [1, 0, 0],
			        [1, 0, 1],
			        [1, 1, 0],
			        [1, 1, 1],
			    )	,  dtype=numpy.floataa	,  )

			# True output values for the given input values.
			a__ :str						  =    numpy.array(([0], [1], [1], [0], [1], [0], [0], [1])	,  dtype=numpy.floataa				)

			# Calling neural network class.
			a__ :Optional[int]						  =    TwoHiddenLayerNeuralNetwork(
			    input_array=a	,  output_array=a				)

			# Calling training function.
			# Set give_loss to True if you want to see loss in every iteration.
			neural_network.train(output=a	,  iterations=10	,  give_loss=a				)

			return neural_network.predict(numpy.array(([1, 1, 1])	,  dtype=numpy.floataa				)				)


if __name__ == "__main__":
		example()






import sys
from collections import defaultdict


class 					lowerCAmelCase_ :




						def __init__(	self						:   Optional[int]						)      ->Any:






									"""simple docstring"""






									a__ :Optional[Any]						  =    []




						def  _snake_case					(	self						:   Optional[Any]   ,     __A						:   List[Any]						)      ->List[str]:






									"""simple docstring"""






									return self.node_position[vertex]




						def  _snake_case					(	self						:   Optional[Any]   ,     __A						:   str   ,     __A						:   Any						)      ->Dict:






									"""simple docstring"""






									a__ :Dict						  =    pos




						def  _snake_case					(	self						:   str   ,     __A						:   Union[str, Any]   ,     __A						:   Union[str, Any]   ,     __A						:   Optional[Any]   ,     __A						:   Optional[int]						)      ->List[Any]:






									"""simple docstring"""






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

															a__ :Any						  =    self.get_position(positions[smallest_child]						)
															self.set_position(
															    positions[smallest_child]   ,     self.get_position(positions[start]						)						)
															self.set_position(positions[start]   ,     __A						)

															self.top_to_bottom(__A   ,     __A   ,     __A   ,     __A						)




						def  _snake_case					(	self						:   List[str]   ,     __A						:   Any   ,     __A						:   List[str]   ,     __A						:   Any   ,     __A						:   str						)      ->Optional[Any]:






									"""simple docstring"""






									a__ :Optional[Any]						  =    position[index]

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

												if val < heap[parent]:
															a__ :int						  =    heap[parent]
															a__ :Optional[Any]						  =    position[parent]
															self.set_position(position[parent]   ,     __A						)
												else:
															a__ :List[Any]						  =    val
															a__ :List[Any]						  =    temp
															self.set_position(__A   ,     __A						)
															break
												a__ :Union[str, Any]						  =    parent
									else:
												a__ :int						  =    val
												a__ :Dict						  =    temp
												self.set_position(__A   ,     0						)




						def  _snake_case					(	self						:   Tuple   ,     __A						:   int   ,     __A						:   int						)      ->Union[str, Any]:






									"""simple docstring"""






									a__ :Tuple						  =    len(__A						) // 2 - 1
									for i in range(__A   ,     -1   ,     -1						):
												self.top_to_bottom(__A   ,     __A   ,     len(__A						)   ,     __A						)






						def  _snake_case					(	self						:   List[Any]   ,     __A						:   List[Any]   ,     __A						:   int						)      ->Optional[Any]:






									"""simple docstring"""






									a__ :Any						  =    positions[0]
									a__ :str						  =    sys.maxsize
									self.top_to_bottom(__A   ,     0   ,     len(__A						)   ,     __A						)
									return temp






def 				lowerCamelCase__	(      a	:   Any				)    ->	Union[str, Any]:





			"""simple docstring"""
			a__ :Tuple						  =    Heap()

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

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

			a__ :Tuple						  =    []
			a__ :Any						  =    1
			a__ :int						  =    sys.maxsize
			for neighbor, distance in adjacency_list[0]:
						a__ :int						  =    0
						a__ :List[str]						  =    distance
			heap.heapify(a	,  a				)

			for _ in range(1	,  len(a				)				):
						a__ :Dict						  =    heap.delete_minimum(a	,  a				)
						if visited[vertex] == 0:
									tree_edges.append((nbr_tv[vertex], vertex)				)
									a__ :Optional[int]						  =    1
									for neighbor, distance in adjacency_list[vertex]:
												if (
												    visited[neighbor] == 0
												    and distance < distance_tv[heap.get_position(a				)]
												):
															a__ :List[str]						  =    distance
															heap.bottom_to_top(
															    a	,  heap.get_position(a				)	,  a	,  a				)
															a__ :str						  =    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))


