

'''simple docstring'''







from __future__ import annotations

import math
import random
from collections.abc import Collection
from typing import overload


class    A__ :



    def __init__(   self						,			UpperCamelCase__ = None    )  -> Optional[int]:





           '''simple docstring'''
           if components is None:
                  A_		   = []
           A_		   = list(__lowerCamelCase    )



    def __len__(   self    )  -> Optional[int]:





           '''simple docstring'''
           return len(self.__components    )



    def __str__(   self    )  -> Tuple:





           '''simple docstring'''
           return "(" + ",".join(map(__lowerCamelCase						,			self.__components    )    ) + ")"



    def __add__(   self						,			UpperCamelCase__    )  -> Optional[int]:





           '''simple docstring'''
           A_		   = len(self    )
           if size == len(__lowerCamelCase    ):
                  A_		   = [self.__components[i] + other.component(__lowerCamelCase    ) for i in range(__lowerCamelCase    )]
                  return Vector(__lowerCamelCase    )
           else:
                  raise Exception("""must have the same size"""    )



    def __sub__(   self						,			UpperCamelCase__    )  -> str:





           '''simple docstring'''
           A_		   = len(self    )
           if size == len(__lowerCamelCase    ):
                  A_		   = [self.__components[i] - other.component(__lowerCamelCase    ) for i in range(__lowerCamelCase    )]
                  return Vector(__lowerCamelCase    )
           else:  # error case
                  raise Exception("""must have the same size"""    )



    @overload
    def __mul__(   self						,			UpperCamelCase__    )  -> str:





           '''simple docstring'''
           ...



    @overload
    def __mul__(   self						,			UpperCamelCase__    )  -> Union[str, Any]:





           '''simple docstring'''
           ...



    def __mul__(   self						,			UpperCamelCase__    )  -> Optional[int]:





           '''simple docstring'''
           if isinstance(__lowerCamelCase						,			(float, int)    ):
                  A_		   = [c * other for c in self.__components]
                  return Vector(__lowerCamelCase    )
           elif isinstance(__lowerCamelCase						,			__lowerCamelCase    ) and len(self    ) == len(__lowerCamelCase    ):
                  A_		   = len(self    )
                  A_		   = [self.__components[i] * other.component(__lowerCamelCase    ) for i in range(__lowerCamelCase    )]
                  return sum(__lowerCamelCase    )
           else:  # error case
                  raise Exception("""invalid operand!"""    )



    def    snake_case_     (   self    )  -> Dict:





           '''simple docstring'''
           return Vector(self.__components    )



    def    snake_case_     (   self						,			UpperCamelCase__    )  -> Union[str, Any]:





           '''simple docstring'''
           if isinstance(__lowerCamelCase						,			__lowerCamelCase    ) and -len(self.__components    ) <= i < len(self.__components    ):
                  return self.__components[i]
           else:
                  raise Exception("""index out of range"""    )



    def    snake_case_     (   self						,			UpperCamelCase__						,			UpperCamelCase__    )  -> Union[str, Any]:





           '''simple docstring'''
           assert -len(self.__components    ) <= pos < len(self.__components    )
           A_		   = value



    def    snake_case_     (   self    )  -> Any:





           '''simple docstring'''
           if len(self.__components    ) == 0:
                  raise Exception("""Vector is empty"""    )
           A_		   = [c**2 for c in self.__components]
           return math.sqrt(sum(__lowerCamelCase    )    )







    def    snake_case_     (   self						,			UpperCamelCase__						,			UpperCamelCase__ = False    )  -> List[str]:





           '''simple docstring'''
           A_		   = self * other
           A_		   = self.euclidean_length() * other.euclidean_length()
           if deg:
                  return math.degrees(math.acos(num / den    )    )
           else:
                  return math.acos(num / den    )

def  UpperCAmelCase__      ( UpperCAmelCase__			)     ->     Vector:
       assert isinstance(UpperCAmelCase__,    UpperCAmelCase__			)
       return Vector([0] * dimension			)
def  UpperCAmelCase__      ( UpperCAmelCase__,    UpperCAmelCase__			)     ->     Vector:
       assert isinstance(UpperCAmelCase__,    UpperCAmelCase__			) and (isinstance(UpperCAmelCase__,    UpperCAmelCase__			))
       A_		   = [0] * dimension
       A_		   = 1
       return Vector(UpperCAmelCase__			)
def  UpperCAmelCase__      ( UpperCAmelCase__,    UpperCAmelCase__,    UpperCAmelCase__			)     ->     Vector:
       assert (
           isinstance(UpperCAmelCase__,    UpperCAmelCase__			)
           and isinstance(UpperCAmelCase__,    UpperCAmelCase__			)
           and (isinstance(UpperCAmelCase__,    (int, float)			))
       )
       return x * scalar + y
def  UpperCAmelCase__      ( UpperCAmelCase__,    UpperCAmelCase__,    UpperCAmelCase__			)     ->     Vector:
       random.seed(UpperCAmelCase__			)
       A_		   = [random.randint(UpperCAmelCase__,    UpperCAmelCase__			) for _ in range(UpperCAmelCase__			)]
       return Vector(UpperCAmelCase__			)


class    A__ :



    def __init__(   self						,			UpperCamelCase__						,			UpperCamelCase__						,			UpperCamelCase__    )  -> Tuple:





           '''simple docstring'''
           A_		   = matrix
           A_		   = w
           A_		   = h



    def __str__(   self    )  -> Dict:





           '''simple docstring'''
           A_		   = """"""
           for i in range(self.__height    ):
                  ans += "|"
                  for j in range(self.__width    ):
                         if j < self.__width - 1:
                                ans += str(self.__matrix[i][j]    ) + ","
                         else:
                                ans += str(self.__matrix[i][j]    ) + "|\n"
           return ans



    def __add__(   self						,			UpperCamelCase__    )  -> int:





           '''simple docstring'''
           if self.__width == other.width() and self.__height == other.height():
                  A_		   = []
                  for i in range(self.__height    ):
                         A_		   = [
                             self.__matrix[i][j] + other.component(__lowerCamelCase						,			__lowerCamelCase    )
                             for j in range(self.__width    )
                         ]
                         matrix.append(__lowerCamelCase    )
                  return Matrix(__lowerCamelCase						,			self.__width						,			self.__height    )
           else:
                  raise Exception("""matrix must have the same dimension!"""    )



    def __sub__(   self						,			UpperCamelCase__    )  -> str:





           '''simple docstring'''
           if self.__width == other.width() and self.__height == other.height():
                  A_		   = []
                  for i in range(self.__height    ):
                         A_		   = [
                             self.__matrix[i][j] - other.component(__lowerCamelCase						,			__lowerCamelCase    )
                             for j in range(self.__width    )
                         ]
                         matrix.append(__lowerCamelCase    )
                  return Matrix(__lowerCamelCase						,			self.__width						,			self.__height    )
           else:
                  raise Exception("""matrices must have the same dimension!"""    )



    @overload
    def __mul__(   self						,			UpperCamelCase__    )  -> Optional[Any]:





           '''simple docstring'''
           ...



    @overload
    def __mul__(   self						,			UpperCamelCase__    )  -> Tuple:





           '''simple docstring'''
           ...



    def __mul__(   self						,			UpperCamelCase__    )  -> Optional[int]:





           '''simple docstring'''
           if isinstance(__lowerCamelCase						,			__lowerCamelCase    ):  # matrix-vector
                  if len(__lowerCamelCase    ) == self.__width:
                         A_		   = zero_vector(self.__height    )
                         for i in range(self.__height    ):
                                A_		   = [
                                    self.__matrix[i][j] * other.component(__lowerCamelCase    )
                                    for j in range(self.__width    )
                                ]
                                ans.change_component(__lowerCamelCase						,			sum(__lowerCamelCase    )    )
                         return ans
                  else:
                         raise Exception(
                             """vector must have the same size as the """
                             """number of columns of the matrix!"""    )
           elif isinstance(__lowerCamelCase						,			(int, float)    ):  # matrix-scalar
                  A_		   = [
                      [self.__matrix[i][j] * other for j in range(self.__width    )]
                      for i in range(self.__height    )
                  ]
                  return Matrix(__lowerCamelCase						,			self.__width						,			self.__height    )
           return None



    def    snake_case_     (   self    )  -> Tuple:





           '''simple docstring'''
           return self.__height



    def    snake_case_     (   self    )  -> Any:





           '''simple docstring'''
           return self.__width



    def    snake_case_     (   self						,			UpperCamelCase__						,			UpperCamelCase__    )  -> Dict:





           '''simple docstring'''
           if 0 <= x < self.__height and 0 <= y < self.__width:
                  return self.__matrix[x][y]
           else:
                  raise Exception("""change_component: indices out of bounds"""    )



    def    snake_case_     (   self						,			UpperCamelCase__						,			UpperCamelCase__						,			UpperCamelCase__    )  -> str:





           '''simple docstring'''
           if 0 <= x < self.__height and 0 <= y < self.__width:
                  A_		   = value
           else:
                  raise Exception("""change_component: indices out of bounds"""    )



    def    snake_case_     (   self						,			UpperCamelCase__						,			UpperCamelCase__    )  -> str:





           '''simple docstring'''
           if self.__height != self.__width:
                  raise Exception("""Matrix is not square"""    )
           A_		   = self.__matrix[:x] + self.__matrix[x + 1 :]
           for i in range(len(__lowerCamelCase    )    ):
                  A_		   = minor[i][:y] + minor[i][y + 1 :]
           return Matrix(__lowerCamelCase						,			self.__width - 1						,			self.__height - 1    ).determinant()



    def    snake_case_     (   self						,			UpperCamelCase__						,			UpperCamelCase__    )  -> str:





           '''simple docstring'''
           if self.__height != self.__width:
                  raise Exception("""Matrix is not square"""    )
           if 0 <= x < self.__height and 0 <= y < self.__width:
                  return (-1) ** (x + y) * self.minor(__lowerCamelCase						,			__lowerCamelCase    )
           else:
                  raise Exception("""Indices out of bounds"""    )







    def    snake_case_     (   self    )  -> str:





           '''simple docstring'''
           if self.__height != self.__width:
                  raise Exception("""Matrix is not square"""    )
           if self.__height < 1:
                  raise Exception("""Matrix has no element"""    )
           elif self.__height == 1:
                  return self.__matrix[0][0]
           elif self.__height == 2:
                  return (
                      self.__matrix[0][0] * self.__matrix[1][1]
                      - self.__matrix[0][1] * self.__matrix[1][0]
                  )
           else:
                  A_		   = [
                      self.__matrix[0][y] * self.cofactor(0						,			__lowerCamelCase    ) for y in range(self.__width    )
                  ]
                  return sum(__lowerCamelCase    )

def  UpperCAmelCase__      ( UpperCAmelCase__			)     ->     Matrix:
       A_		   = [[0] * n for _ in range(UpperCAmelCase__			)]
       return Matrix(UpperCAmelCase__,    UpperCAmelCase__,    UpperCAmelCase__			)







def  UpperCAmelCase__      ( UpperCAmelCase__,    UpperCAmelCase__,    UpperCAmelCase__,    UpperCAmelCase__			)     ->     Matrix:
       random.seed(UpperCAmelCase__			)
       A_		   = [
           [random.randint(UpperCAmelCase__,    UpperCAmelCase__			) for _ in range(UpperCAmelCase__			)] for _ in range(UpperCAmelCase__			)
       ]
       return Matrix(UpperCAmelCase__,    UpperCAmelCase__,    UpperCAmelCase__			)



'''simple docstring'''







def  UpperCAmelCase__      ( UpperCAmelCase__ = 10_00			)     ->     int:
       return sum(2 * a * ((a - 1) // 2) for a in range(3,    n + 1			)			)


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