"""simple docstring"""




from __future__ import annotations

from typing import Generic, TypeVar

__lowerCAmelCase    :							int													=						TypeVar("T")

class       a_      (     Generic[T]			):




					def __init__(	self						:     List[Any]  ,						snake_case__						:     T     ):
							lowerCAmelCase__        =   data
							lowerCAmelCase__        =   self
							lowerCAmelCase__        =   0

class       a_      (     Generic[T]			):




					def __init__(	self						:     Optional[int]     ):
							# map from node name to the node object
							lowerCAmelCase__        =   {}




					def 						_SCREAMING_SNAKE_CASE						(	self						:     List[Any]  ,						snake_case__						:     T     ):
							# create a new set with x as its member
							lowerCAmelCase__        =   DisjointSetTreeNode(snake_case__     )




					def 						_SCREAMING_SNAKE_CASE						(	self						:     List[Any]  ,						snake_case__						:     T     ):
							# find the set x belongs to (with path-compression)
							lowerCAmelCase__        =   self.map[data]
							if elem_ref != elem_ref.parent:
									lowerCAmelCase__        =   self.find_set(elem_ref.parent.data     )
							return elem_ref.parent




					def 						_SCREAMING_SNAKE_CASE						(	self						:     str  ,						snake_case__						:     DisjointSetTreeNode[T]  ,						snake_case__						:     DisjointSetTreeNode[T]     ):
							# helper function for union operation
							if nodea.rank > nodea.rank:
									lowerCAmelCase__        =   nodea
							else:
									lowerCAmelCase__        =   nodea
									if nodea.rank == nodea.rank:
											nodea.rank += 1




					def 						_SCREAMING_SNAKE_CASE						(	self						:     List[str]  ,						snake_case__						:     T  ,						snake_case__						:     T     ):
							# merge 2 disjoint sets
							self.link(self.find_set(snake_case__     )  ,						self.find_set(snake_case__     )     )

class       a_      (     Generic[T]			):




					def __init__(	self						:     List[Any]     ):
							# connections: map from the node to the neighbouring nodes (with weights)
							lowerCAmelCase__        =   {}




					def 						_SCREAMING_SNAKE_CASE						(	self						:     str  ,						snake_case__						:     T     ):
							# add a node ONLY if its not present in the graph
							if node not in self.connections:
									lowerCAmelCase__        =   {}




					def 						_SCREAMING_SNAKE_CASE						(	self						:     List[str]  ,						snake_case__						:     T  ,						snake_case__						:     T  ,						snake_case__						:     int     ):
							# add an edge with the given weight
							self.add_node(snake_case__     )
							self.add_node(snake_case__     )
							lowerCAmelCase__        =   weight
							lowerCAmelCase__        =   weight




					def 						_SCREAMING_SNAKE_CASE						(	self						:     List[Any]     ):
							lowerCAmelCase__        =   []
							lowerCAmelCase__        =   set()
							for start in self.connections:
									for end in self.connections[start]:
											if (start, end) not in seen:
													seen.add((end, start)     )
													edges.append((start, end, self.connections[start][end])     )
							edges.sort(key=lambda snake_case__     : x[2]     )

							# creating the disjoint set
							lowerCAmelCase__        =   DisjointSetTree[T]()
							for node in self.connections:
									disjoint_set.make_set(snake_case__     )

							# MST generation
							lowerCAmelCase__        =   0
							lowerCAmelCase__        =   0
							lowerCAmelCase__        =   GraphUndirectedWeighted[T]()
							while num_edges < len(self.connections     ) - 1:
									lowerCAmelCase__   ,					lowerCAmelCase__   ,					lowerCAmelCase__        =   edges[index]
									index += 1
									lowerCAmelCase__        =   disjoint_set.find_set(snake_case__     )
									lowerCAmelCase__        =   disjoint_set.find_set(snake_case__     )
									if parent_u != parent_v:
											num_edges += 1
											graph.add_edge(snake_case__  ,						snake_case__  ,						snake_case__     )
											disjoint_set.union(snake_case__  ,						snake_case__     )
							return graph





"""simple docstring"""




import os
from math import logaa







def 							_UpperCAmelCase		(       lowerCamelCase__ = "base_exp.txt"     ):





		"""simple docstring"""




		lowerCAmelCase__        =   0
		lowerCAmelCase__        =   0
		for i, line in enumerate(open(os.path.join(os.path.dirname(lowerCamelCase__     )			,  lowerCamelCase__     )     )     ):
				lowerCAmelCase__   ,					lowerCAmelCase__        =   list(map(lowerCamelCase__			,  line.split(""","""     )     )     )
				if x * logaa(lowerCamelCase__     ) > largest:
						lowerCAmelCase__        =   x * logaa(lowerCamelCase__     )
						lowerCAmelCase__        =   i + 1
		return result


if __name__ == "__main__":
			print(solution())




