

from __future__ import annotations

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



class        A__:
						"""simple docstring"""






						def __init__(    self  ,      _lowercase = None    )     -> None:
									if components is None:
												a_						:						Optional[Any] 							= []
									a_						:						str 							= list(_lowercase    )





						def __len__(    self    )     -> int:
									return len(self.__components    )





						def __str__(    self    )     -> str:
									return "(" + ",".join(map(_lowercase  ,      self.__components    )    ) + ")"





						def __add__(    self  ,      _lowercase    )     -> Vector:
									a_						:						Optional[Any] 							= len(self    )
									if size == len(_lowercase    ):
												a_						:						Union[str, Any] 							= [self.__components[i] + other.component(_lowercase    ) for i in range(_lowercase    )]
												return Vector(_lowercase    )
									else:
												raise Exception("""must have the same size"""    )





						def __sub__(    self  ,      _lowercase    )     -> Vector:
									a_						:						Tuple 							= len(self    )
									if size == len(_lowercase    ):
												a_						:						Any 							= [self.__components[i] - other.component(_lowercase    ) for i in range(_lowercase    )]
												return Vector(_lowercase    )
									else:  # error case
												raise Exception("""must have the same size"""    )





						@overload
						def __mul__(    self  ,      _lowercase    )     -> Vector:
									...





						@overload
						def __mul__(    self  ,      _lowercase    )     -> float:
									...





						def __mul__(    self  ,      _lowercase    )     -> float | Vector:
									if isinstance(_lowercase  ,      (float, int)    ):
												a_						:						Tuple 							= [c * other for c in self.__components]
												return Vector(_lowercase    )
									elif isinstance(_lowercase  ,      _lowercase    ) and len(self    ) == len(_lowercase    ):
												a_						:						Any 							= len(self    )
												a_						:						List[str] 							= [self.__components[i] * other.component(_lowercase    ) for i in range(_lowercase    )]
												return sum(_lowercase    )
									else:  # error case
												raise Exception("""invalid operand!"""    )





						def 			UpperCamelCase__					(    self    )     -> Vector:
									return Vector(self.__components    )





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





						def 			UpperCamelCase__					(    self  ,      _lowercase  ,      _lowercase    )     -> None:
									assert -len(self.__components    ) <= pos < len(self.__components    )
									a_						:						str 							= value





						def 			UpperCamelCase__					(    self    )     -> float:
									if len(self.__components    ) == 0:
												raise Exception("""Vector is empty"""    )
									a_						:						List[str] 							= [c**2 for c in self.__components]
									return math.sqrt(sum(_lowercase    )    )





						def 			UpperCamelCase__					(    self  ,      _lowercase  ,      _lowercase = False    )     -> float:
									a_						:						List[str] 							= self * other
									a_						:						Dict 							= self.euclidean_length() * other.euclidean_length()
									if deg:
												return math.degrees(math.acos(num / den    )    )
									else:
												return math.acos(num / den    )







def 					_UpperCAmelCase				(						a__):

			'''simple docstring'''



			assert isinstance(a__  ,	a__)
			return Vector([0] * dimension)


def 					_UpperCAmelCase				(						a__  ,	a__):

			'''simple docstring'''



			assert isinstance(a__  ,	a__) and (isinstance(a__  ,	a__))
			a_						:						Any 							= [0] * dimension
			a_						:						Tuple 							= 1
			return Vector(a__)


def 					_UpperCAmelCase				(						a__  ,	a__  ,	a__):

			'''simple docstring'''



			assert (
			    isinstance(a__  ,	a__)
			    and isinstance(a__  ,	a__)
			    and (isinstance(a__  ,	(int, float)))
			)
			return x * scalar + y


def 					_UpperCAmelCase				(						a__  ,	a__  ,	a__):

			'''simple docstring'''



			random.seed(a__)
			a_						:						Optional[Any] 							= [random.randint(a__  ,	a__) for _ in range(a__)]
			return Vector(a__)



class        A__:
						"""simple docstring"""






						def __init__(    self  ,      _lowercase  ,      _lowercase  ,      _lowercase    )     -> None:
									a_						:						Dict 							= matrix
									a_						:						List[str] 							= w
									a_						:						str 							= h





						def __str__(    self    )     -> str:
									a_						:						Optional[int] 							= """"""
									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  ,      _lowercase    )     -> Matrix:
									if self.__width == other.width() and self.__height == other.height():
												a_						:						Optional[int] 							= []
												for i in range(self.__height    ):
															a_						:						List[Any] 							= [
															    self.__matrix[i][j] + other.component(_lowercase  ,      _lowercase    )
															    for j in range(self.__width    )
															]
															matrix.append(_lowercase    )
												return Matrix(_lowercase  ,      self.__width  ,      self.__height    )
									else:
												raise Exception("""matrix must have the same dimension!"""    )





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





						@overload
						def __mul__(    self  ,      _lowercase    )     -> Matrix:
									...





						@overload
						def __mul__(    self  ,      _lowercase    )     -> Vector:
									...





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





						def 			UpperCamelCase__					(    self    )     -> int:
									return self.__height





						def 			UpperCamelCase__					(    self    )     -> int:
									return self.__width





						def 			UpperCamelCase__					(    self  ,      _lowercase  ,      _lowercase    )     -> float:
									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 			UpperCamelCase__					(    self  ,      _lowercase  ,      _lowercase  ,      _lowercase    )     -> None:
									if 0 <= x < self.__height and 0 <= y < self.__width:
												a_						:						str 							= value
									else:
												raise Exception("""change_component: indices out of bounds"""    )





						def 			UpperCamelCase__					(    self  ,      _lowercase  ,      _lowercase    )     -> float:
									if self.__height != self.__width:
												raise Exception("""Matrix is not square"""    )
									a_						:						List[Any] 							= self.__matrix[:x] + self.__matrix[x + 1 :]
									for i in range(len(_lowercase    )    ):
												a_						:						Optional[int] 							= minor[i][:y] + minor[i][y + 1 :]
									return Matrix(_lowercase  ,      self.__width - 1  ,      self.__height - 1    ).determinant()





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





						def 			UpperCamelCase__					(    self    )     -> float:
									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_						:						Optional[int] 							= [
												    self.__matrix[0][y] * self.cofactor(0  ,      _lowercase    ) for y in range(self.__width    )
												]
												return sum(_lowercase    )







def 					_UpperCAmelCase				(						a__):

			'''simple docstring'''



			a_						:						list[list[float]] 							= [[0] * n for _ in range(a__)]
			return Matrix(a__  ,	a__  ,	a__)



def 					_UpperCAmelCase				(						a__  ,	a__  ,	a__  ,	a__):

			'''simple docstring'''



			random.seed(a__)
			a_						:						list[list[float]] 							= [
			    [random.randint(a__  ,	a__) for _ in range(a__)] for _ in range(a__)
			]
			return Matrix(a__  ,	a__  ,	a__)





from __future__ import annotations

# This is the precision for this function which can be altered.
# It is recommended for users to keep this number greater than or equal to 10.
__snake_case				:      Optional[Any]   		=			10


def 					_UpperCAmelCase				(						a__  ,	a__  ,	a__  ,	a__):

			'''simple docstring'''



			for i in range(a__  ,	a__):
						if array[i] == target:
									return i
			return -1


def 					_UpperCAmelCase				(						a__  ,	a__):

			'''simple docstring'''



			a_						:						Any 							= 0
			a_						:						List[str] 							= len(a__)
			while left <= right:
						if right - left < precision:
									return lin_search(a__  ,	a__  ,	a__  ,	a__)

						a_						:						Dict 							= (left + right) // 3 + 1
						a_						:						Optional[Any] 							= 2 * (left + right) // 3 + 1

						if array[one_third] == target:
									return one_third
						elif array[two_third] == target:
									return two_third

						elif target < array[one_third]:
									a_						:						int 							= one_third - 1
						elif array[two_third] < target:
									a_						:						Any 							= two_third + 1

						else:
									a_						:						Optional[int] 							= one_third + 1
									a_						:						int 							= two_third - 1
			else:
						return -1


def 					_UpperCAmelCase				(						a__  ,	a__  ,	a__  ,	a__):

			'''simple docstring'''



			if left < right:
						if right - left < precision:
									return lin_search(a__  ,	a__  ,	a__  ,	a__)
						a_						:						Optional[int] 							= (left + right) // 3 + 1
						a_						:						Union[str, Any] 							= 2 * (left + right) // 3 + 1

						if array[one_third] == target:
									return one_third
						elif array[two_third] == target:
									return two_third

						elif target < array[one_third]:
									return rec_ternary_search(a__  ,	one_third - 1  ,	a__  ,	a__)
						elif array[two_third] < target:
									return rec_ternary_search(two_third + 1  ,	a__  ,	a__  ,	a__)
						else:
									return rec_ternary_search(one_third + 1  ,	two_third - 1  ,	a__  ,	a__)
			else:
						return -1


if __name__ == "__main__":
	import doctest

	doctest.testmod()

	__snake_case				:      Optional[int]   		=			input("""Enter numbers separated by comma:\n""").strip()
	__snake_case				:      Optional[int]   		=			[int(item.strip()) for item in user_input.split(""",""")]
	assert collection == sorted(collection), F"List must be ordered.\n{collection}."
	__snake_case				:      int   		=			int(input("""Enter the number to be found in the list:\n""").strip())
	__snake_case				:      List[Any]   		=			ite_ternary_search(collection, target)
	__snake_case				:      Optional[int]   		=			rec_ternary_search(0, len(collection) - 1, collection, target)
	if resulta != -1:
		print(F"""Iterative search: {target} found at positions: {resulta}""")
		print(F"""Recursive search: {target} found at positions: {resulta}""")
	else:
		print("""Not found""")


