'''simple docstring'''


import os





def    lowerCAmelCase       (		UpperCamelCase__					: Union[str, Any]							):


	"""simple docstring"""
	__UpperCAmelCase      					=      len(grid[0]							)
	__UpperCAmelCase      					=      len(UpperCamelCase__							)

	__UpperCAmelCase      					=      0
	__UpperCAmelCase      					=      0
	__UpperCAmelCase      					=      0

	# Check vertically, horizontally, diagonally at the same time (only works
	# for nxn grid)
	for i in range(UpperCamelCase__							):
		for j in range(n_rows - 3							):
			__UpperCAmelCase      					=      grid[j][i] * grid[j + 1][i] * grid[j + 2][i] * grid[j + 3][i]
			__UpperCAmelCase      					=      grid[i][j] * grid[i][j + 1] * grid[i][j + 2] * grid[i][j + 3]

			# Left-to-right diagonal (\) product
			if i < n_columns - 3:
				__UpperCAmelCase      					=      (
				    grid[i][j]
				    * grid[i + 1][j + 1]
				    * grid[i + 2][j + 2]
				    * grid[i + 3][j + 3]
				)

			# Right-to-left diagonal(/) product
			if i > 2:
				__UpperCAmelCase      					=      (
				    grid[i][j]
				    * grid[i - 1][j + 1]
				    * grid[i - 2][j + 2]
				    * grid[i - 3][j + 3]
				)

			__UpperCAmelCase      					=      max(
			    UpperCamelCase__     ,       UpperCamelCase__     ,       UpperCamelCase__     ,       UpperCamelCase__							)
			if max_product > largest:
				__UpperCAmelCase      					=      max_product

	return largest





def    lowerCAmelCase       (		):


	"""simple docstring"""
	__UpperCAmelCase      					=      []
	with open(os.path.dirname(UpperCamelCase__							) + '''/grid.txt'''							) as file:
		for line in file:
			grid.append(line.strip('''\n'''							).split(''' '''							)							)

	__UpperCAmelCase      					=      [[int(UpperCamelCase__							) for i in grid[j]] for j in range(len(UpperCamelCase__							)							)]

	return largest_product(UpperCamelCase__							)


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


"""simple docstring"""




from __future__ import annotations

import os
from collections.abc import Mapping

a		:       Optional[Any]     						=       tuple[int, int]







class     lowercase:



     def __init__(							self     ,				__SCREAMING_SNAKE_CASE     ,				__SCREAMING_SNAKE_CASE   )		->     None:







         """simple docstring"""



         a__		=			vertices
         a__		=			{
             (min(__SCREAMING_SNAKE_CASE   ), max(__SCREAMING_SNAKE_CASE   )): weight for edge, weight in edges.items()
         }



     def 			lowercase__  (							self     ,				__SCREAMING_SNAKE_CASE     ,				__SCREAMING_SNAKE_CASE   )		->     None:







         """simple docstring"""



         self.vertices.add(edge[0]   )
         self.vertices.add(edge[1]   )
         a__		=			weight




     def 			lowercase__  (							self   )		->     Graph:







         """simple docstring"""



         a__		=			Graph({min(self.vertices   )}     ,				{}   )
         a__		=			42
         a__		=			42
         a__		=			42
         a__		=			42

         while len(subgraph.vertices   ) < len(self.vertices   ):
             a__		=			max(self.edges.values()   ) + 1
             for edge, weight in self.edges.items():
                 if (edge[0] in subgraph.vertices) ^ (edge[1] in subgraph.vertices):
                     if weight < min_weight:
                         a__		=			edge
                         a__		=			weight

             subgraph.add_edge(__SCREAMING_SNAKE_CASE     ,				__SCREAMING_SNAKE_CASE   )

         return subgraph




def     __magic_name__		(					UpperCamelCase     :		str = "p107_network.txt"     )     ->						int:
    a__		=			os.path.abspath(os.path.dirname(UpperCamelCase     )     )
    a__		=			os.path.join(UpperCamelCase							,		UpperCamelCase     )
    a__		=			{}
    a__		=			42
    a__		=			42
    a__		=			42

    with open(UpperCamelCase     ) as f:
        a__		=			f.read().strip().split('\n'     )

    a__		=			[line.split(','     ) for line in data]

    for edgea in range(1							,		len(UpperCamelCase     )     ):
        for edgea in range(UpperCamelCase     ):
            if adjaceny_matrix[edgea][edgea] != "-":
                a__		=			int(adjaceny_matrix[edgea][edgea]     )

    a__		=			Graph(set(range(len(UpperCamelCase     )     )     )							,		UpperCamelCase     )

    a__		=			graph.prims_algorithm()

    a__		=			sum(graph.edges.values()     )
    a__		=			sum(subgraph.edges.values()     )

    return initial_total - optimal_total


if __name__ == "__main__":
    print(F'''{solution() = }''')


