



from __future__ import annotations

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





class  __magic_name__   :






		def __init__(						self      :     List[str]				,		UpperCamelCase__      :     Collection[float] | None = None      )				->					None:
								'''simple docstring'''







								if components is None:
														UpperCAmelCase         =     []
								UpperCAmelCase         =     list(UpperCamelCase__      )






		def __len__(						self      :     Dict      )				->					int:
								'''simple docstring'''







								return len(self.__components      )






		def __str__(						self      :     Union[str, Any]      )				->					str:
								'''simple docstring'''







								return "(" + ",".join(map(UpperCamelCase__				,		self.__components      )      ) + ")"






		def __add__(						self      :     Optional[Any]				,		UpperCamelCase__      :     Vector      )				->					Vector:
								'''simple docstring'''







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






		def __sub__(						self      :     Any				,		UpperCamelCase__      :     Vector      )				->					Vector:
								'''simple docstring'''







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






		@overload
		def __mul__(						self      :     Any				,		UpperCamelCase__      :     float      )				->					Vector:
								'''simple docstring'''







								...






		@overload
		def __mul__(						self      :     Optional[int]				,		UpperCamelCase__      :     Vector      )				->					float:
								'''simple docstring'''







								...






		def __mul__(						self      :     int				,		UpperCamelCase__      :     float | Vector      )				->					float | Vector:
								'''simple docstring'''







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






		def SCREAMING_SNAKE_CASE_			(						self      :     Optional[int]      )				->					Vector:
								'''simple docstring'''







								return Vector(self.__components      )






		def SCREAMING_SNAKE_CASE_			(						self      :     Dict				,		UpperCamelCase__      :     int      )				->					float:
								'''simple docstring'''







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






		def SCREAMING_SNAKE_CASE_			(						self      :     Union[str, Any]				,		UpperCamelCase__      :     int				,		UpperCamelCase__      :     float      )				->					None:
								'''simple docstring'''







								assert -len(self.__components      ) <= pos < len(self.__components      )
								UpperCAmelCase         =     value






		def SCREAMING_SNAKE_CASE_			(						self      :     str      )				->					float:
								'''simple docstring'''







								if len(self.__components      ) == 0:
														raise Exception("Vector is empty"      )
								UpperCAmelCase         =     [c**2 for c in self.__components]
								return math.sqrt(sum(UpperCamelCase__      )      )







		def SCREAMING_SNAKE_CASE_			(						self      :     Dict				,		UpperCamelCase__      :     Vector				,		UpperCamelCase__      :     bool = False      )				->					float:
								'''simple docstring'''







								UpperCAmelCase         =     self * other
								UpperCAmelCase         =     self.euclidean_length() * other.euclidean_length()
								if deg:
														return math.degrees(math.acos(num / den      )      )
								else:
														return math.acos(num / den      )

def    lowerCamelCase_(lowerCamelCase_    ) ->       str:
						assert isinstance(_lowerCamelCase    ,   _lowerCamelCase    )
						return Vector([0] * dimension    )

def    lowerCamelCase_(lowerCamelCase_    ,   lowerCamelCase_    ) ->       List[str]:
						assert isinstance(_lowerCamelCase    ,   _lowerCamelCase    ) and (isinstance(_lowerCamelCase    ,   _lowerCamelCase    ))
						UpperCAmelCase         =     [0] * dimension
						UpperCAmelCase         =     1
						return Vector(_lowerCamelCase    )

def    lowerCamelCase_(lowerCamelCase_    ,   lowerCamelCase_    ,   lowerCamelCase_    ) ->       Dict:
						assert (
						    isinstance(_lowerCamelCase    ,   _lowerCamelCase    )
						    and isinstance(_lowerCamelCase    ,   _lowerCamelCase    )
						    and (isinstance(_lowerCamelCase    ,   (int, float)    ))
						)
						return x * scalar + y

def    lowerCamelCase_(lowerCamelCase_    ,   lowerCamelCase_    ,   lowerCamelCase_    ) ->       int:
						random.seed(_lowerCamelCase    )
						UpperCAmelCase         =     [random.randint(_lowerCamelCase    ,   _lowerCamelCase    ) for _ in range(_lowerCamelCase    )]
						return Vector(_lowerCamelCase    )





class  __magic_name__   :






		def __init__(						self      :     Optional[Any]				,		UpperCamelCase__      :     list[list[float]]				,		UpperCamelCase__      :     int				,		UpperCamelCase__      :     int      )				->					None:
								'''simple docstring'''







								UpperCAmelCase         =     matrix
								UpperCAmelCase         =     w
								UpperCAmelCase         =     h






		def __str__(						self      :     int      )				->					str:
								'''simple docstring'''







								UpperCAmelCase         =     ""
								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      :     Optional[Any]				,		UpperCamelCase__      :     Matrix      )				->					Matrix:
								'''simple docstring'''







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






		def __sub__(						self      :     int				,		UpperCamelCase__      :     Matrix      )				->					Matrix:
								'''simple docstring'''







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






		@overload
		def __mul__(						self      :     Tuple				,		UpperCamelCase__      :     float      )				->					Matrix:
								'''simple docstring'''







								...






		@overload
		def __mul__(						self      :     int				,		UpperCamelCase__      :     Vector      )				->					Vector:
								'''simple docstring'''







								...






		def __mul__(						self      :     Dict				,		UpperCamelCase__      :     float | Vector      )				->					Vector | Matrix:
								'''simple docstring'''







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






		def SCREAMING_SNAKE_CASE_			(						self      :     List[str]      )				->					int:
								'''simple docstring'''







								return self.__height






		def SCREAMING_SNAKE_CASE_			(						self      :     int      )				->					int:
								'''simple docstring'''







								return self.__width






		def SCREAMING_SNAKE_CASE_			(						self      :     str				,		UpperCamelCase__      :     int				,		UpperCamelCase__      :     int      )				->					float:
								'''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 SCREAMING_SNAKE_CASE_			(						self      :     Any				,		UpperCamelCase__      :     int				,		UpperCamelCase__      :     int				,		UpperCamelCase__      :     float      )				->					None:
								'''simple docstring'''







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






		def SCREAMING_SNAKE_CASE_			(						self      :     Optional[Any]				,		UpperCamelCase__      :     int				,		UpperCamelCase__      :     int      )				->					float:
								'''simple docstring'''







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






		def SCREAMING_SNAKE_CASE_			(						self      :     Dict				,		UpperCamelCase__      :     int				,		UpperCamelCase__      :     int      )				->					float:
								'''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(UpperCamelCase__				,		UpperCamelCase__      )
								else:
														raise Exception("Indices out of bounds"      )







		def SCREAMING_SNAKE_CASE_			(						self      :     List[str]      )				->					float:
								'''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:
														UpperCAmelCase         =     [
														    self.__matrix[0][y] * self.cofactor(0				,		UpperCamelCase__      ) for y in range(self.__width      )
														]
														return sum(UpperCamelCase__      )

def    lowerCamelCase_(lowerCamelCase_    ) ->       Optional[int]:
						UpperCAmelCase         =     [[0] * n for _ in range(_lowerCamelCase    )]
						return Matrix(_lowerCamelCase    ,   _lowerCamelCase    ,   _lowerCamelCase    )





def    lowerCamelCase_(lowerCamelCase_    ,   lowerCamelCase_    ,   lowerCamelCase_    ,   lowerCamelCase_    ) ->       Optional[int]:
						random.seed(_lowerCamelCase    )
						UpperCAmelCase         =     [
						    [random.randint(_lowerCamelCase    ,   _lowerCamelCase    ) for _ in range(_lowerCamelCase    )] for _ in range(_lowerCamelCase    )
						]
						return Matrix(_lowerCamelCase    ,   _lowerCamelCase    ,   _lowerCamelCase    )








def    lowerCamelCase_(lowerCamelCase_ = 600_851_475_143    ) ->       int:

						try:
												UpperCAmelCase         =     int(lowerCamelCase_    )
						except (TypeError, ValueError):
												raise TypeError("Parameter n must be int or castable to int."    )
						if n <= 0:
												raise ValueError("Parameter n must be greater than or equal to one."    )
						UpperCAmelCase         =     1
						UpperCAmelCase         =     2
						while i * i <= n:
												while n % i == 0:
																		UpperCAmelCase         =     i
																		n //= i
												i += 1
						if n > 1:
												UpperCAmelCase         =     n
						return int(lowerCamelCase_    )


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



