






"""simple docstring"""






from __future__ import annotations

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




class 							lowerCAmelCase__				:






      '''simple docstring'''

      def __init__(						self     :  Optional[int]						,	lowercase_     :  Collection[float] | None = None):




          '''simple docstring'''


          if components is None:
              SCREAMING_SNAKE_CASE_      :  Optional[Any]    						=		[]
          SCREAMING_SNAKE_CASE_      :  int    						=		list(lowercase_)
      def __len__(						self     :  Optional[int]):




          '''simple docstring'''


          return len(self.__components)
      def __str__(						self     :  List[Any]):




          '''simple docstring'''


          return "(" + ",".join(map(lowercase_						,	self.__components)) + ")"
      def __add__(						self     :  Dict						,	lowercase_     :  Vector):




          '''simple docstring'''


          SCREAMING_SNAKE_CASE_      :  Dict    						=		len(self)
          if size == len(lowercase_):
              SCREAMING_SNAKE_CASE_      :  Dict    						=		[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     :  Union[str, Any]						,	lowercase_     :  Vector):




          '''simple docstring'''


          SCREAMING_SNAKE_CASE_      :  Optional[Any]    						=		len(self)
          if size == len(lowercase_):
              SCREAMING_SNAKE_CASE_      :  Optional[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     :  Optional[Any]						,	lowercase_     :  float):




          '''simple docstring'''


          ...
      @overload
      def __mul__(						self     :  Union[str, Any]						,	lowercase_     :  Vector):




          '''simple docstring'''


          ...
      def __mul__(						self     :  int						,	lowercase_     :  float | Vector):




          '''simple docstring'''


          if isinstance(lowercase_						,	(float, int)):
              SCREAMING_SNAKE_CASE_      :  int    						=		[c * other for c in self.__components]
              return Vector(lowercase_)
          elif isinstance(lowercase_						,	lowercase_) and len(self) == len(lowercase_):
              SCREAMING_SNAKE_CASE_      :  Optional[int]    						=		len(self)
              SCREAMING_SNAKE_CASE_      :  List[str]    						=		[self.__components[i] * other.component(lowercase_) for i in range(lowercase_)]
              return sum(lowercase_)
          else:  # error case
              raise Exception('''invalid operand!''')
      def _SCREAMING_SNAKE_CASE (						self     :  Dict):




          '''simple docstring'''


          return Vector(self.__components)
      def _SCREAMING_SNAKE_CASE (						self     :  Optional[int]						,	lowercase_     :  int):




          '''simple docstring'''


          if isinstance(lowercase_						,	lowercase_) and -len(self.__components) <= i < len(self.__components):
              return self.__components[i]
          else:
              raise Exception('''index out of range''')
      def _SCREAMING_SNAKE_CASE (						self     :  Any						,	lowercase_     :  int						,	lowercase_     :  float):




          '''simple docstring'''


          assert -len(self.__components) <= pos < len(self.__components)
          SCREAMING_SNAKE_CASE_      :  Any    						=		value
      def _SCREAMING_SNAKE_CASE (						self     :  Union[str, Any]):




          '''simple docstring'''


          if len(self.__components) == 0:
              raise Exception('''Vector is empty''')
          SCREAMING_SNAKE_CASE_      :  Dict    						=		[c**2 for c in self.__components]
          return math.sqrt(sum(lowercase_))



      def _SCREAMING_SNAKE_CASE (						self     :  Optional[Any]						,	lowercase_     :  Vector						,	lowercase_     :  bool = False):




          '''simple docstring'''


          SCREAMING_SNAKE_CASE_      :  Union[str, Any]    						=		self * other
          SCREAMING_SNAKE_CASE_      :  Any    						=		self.euclidean_length() * other.euclidean_length()
          if deg:
              return math.degrees(math.acos(num / den))
          else:
              return math.acos(num / den)



def 					_A			(__a							) ->       Vector:
    """simple docstring"""






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



def 					_A			(__a    ,				__a							) ->       Vector:
    """simple docstring"""






    assert isinstance(__a    ,				__a							) and (isinstance(__a    ,				__a							))
    SCREAMING_SNAKE_CASE_      :  List[str]    						=		[0] * dimension
    SCREAMING_SNAKE_CASE_      :  Union[str, Any]    						=		1
    return Vector(__a							)



def 					_A			(__a    ,				__a    ,				__a							) ->       Vector:
    """simple docstring"""






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



def 					_A			(__a    ,				__a    ,				__a							) ->       Vector:
    """simple docstring"""






    random.seed(__a							)
    SCREAMING_SNAKE_CASE_      :  List[str]    						=		[random.randint(__a    ,				__a							) for _ in range(__a							)]
    return Vector(__a							)




class 							lowerCAmelCase__				:






      '''simple docstring'''

      def __init__(						self     :  Any						,	lowercase_     :  list[list[float]]						,	lowercase_     :  int						,	lowercase_     :  int):




          '''simple docstring'''


          SCREAMING_SNAKE_CASE_      :  Any    						=		matrix
          SCREAMING_SNAKE_CASE_      :  Any    						=		w
          SCREAMING_SNAKE_CASE_      :  Union[str, Any]    						=		h
      def __str__(						self     :  Dict):




          '''simple docstring'''


          SCREAMING_SNAKE_CASE_      :  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     :  str						,	lowercase_     :  Matrix):




          '''simple docstring'''


          if self.__width == other.width() and self.__height == other.height():
              SCREAMING_SNAKE_CASE_      :  Tuple    						=		[]
              for i in range(self.__height):
                  SCREAMING_SNAKE_CASE_      :  Tuple    						=		[
                      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     :  Optional[Any]						,	lowercase_     :  Matrix):




          '''simple docstring'''


          if self.__width == other.width() and self.__height == other.height():
              SCREAMING_SNAKE_CASE_      :  Optional[int]    						=		[]
              for i in range(self.__height):
                  SCREAMING_SNAKE_CASE_      :  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     :  str						,	lowercase_     :  float):




          '''simple docstring'''


          ...
      @overload
      def __mul__(						self     :  Optional[int]						,	lowercase_     :  Vector):




          '''simple docstring'''


          ...
      def __mul__(						self     :  List[str]						,	lowercase_     :  float | Vector):




          '''simple docstring'''


          if isinstance(lowercase_						,	lowercase_):  # matrix-vector
              if len(lowercase_) == self.__width:
                  SCREAMING_SNAKE_CASE_      :  Optional[Any]    						=		zero_vector(self.__height)
                  for i in range(self.__height):
                      SCREAMING_SNAKE_CASE_      :  int    						=		[
                          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
              SCREAMING_SNAKE_CASE_      :  Optional[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 _SCREAMING_SNAKE_CASE (						self     :  Optional[Any]):




          '''simple docstring'''


          return self.__height
      def _SCREAMING_SNAKE_CASE (						self     :  Tuple):




          '''simple docstring'''


          return self.__width
      def _SCREAMING_SNAKE_CASE (						self     :  List[Any]						,	lowercase_     :  int						,	lowercase_     :  int):




          '''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     :  Optional[Any]						,	lowercase_     :  int						,	lowercase_     :  int						,	lowercase_     :  float):




          '''simple docstring'''


          if 0 <= x < self.__height and 0 <= y < self.__width:
              SCREAMING_SNAKE_CASE_      :  Dict    						=		value
          else:
              raise Exception('''change_component: indices out of bounds''')
      def _SCREAMING_SNAKE_CASE (						self     :  Optional[int]						,	lowercase_     :  int						,	lowercase_     :  int):




          '''simple docstring'''


          if self.__height != self.__width:
              raise Exception('''Matrix is not square''')
          SCREAMING_SNAKE_CASE_      :  int    						=		self.__matrix[:x] + self.__matrix[x + 1 :]
          for i in range(len(lowercase_)):
              SCREAMING_SNAKE_CASE_      :  int    						=		minor[i][:y] + minor[i][y + 1 :]
          return Matrix(lowercase_						,	self.__width - 1						,	self.__height - 1).determinant()
      def _SCREAMING_SNAKE_CASE (						self     :  Tuple						,	lowercase_     :  int						,	lowercase_     :  int):




          '''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(lowercase_						,	lowercase_)
          else:
              raise Exception('''Indices out of bounds''')



      def _SCREAMING_SNAKE_CASE (						self     :  List[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:
              SCREAMING_SNAKE_CASE_      :  int    						=		[
                  self.__matrix[0][y] * self.cofactor(0						,	lowercase_) for y in range(self.__width)
              ]
              return sum(lowercase_)



def 					_A			(__a							) ->       Matrix:
    """simple docstring"""






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





def 					_A			(__a    ,				__a    ,				__a    ,				__a							) ->       Matrix:
    """simple docstring"""






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










"""simple docstring"""






import random
from typing import Any



def 					_A			(__a							) ->       list[Any]:
    """simple docstring"""






    for _ in range(len(__a							)							):
        SCREAMING_SNAKE_CASE_      :  Optional[int]    						=		random.randint(0    ,				len(__a							) - 1							)
        SCREAMING_SNAKE_CASE_      :  Tuple    						=		random.randint(0    ,				len(__a							) - 1							)
        SCREAMING_SNAKE_CASE_						,			SCREAMING_SNAKE_CASE_      :  Union[str, Any]    						=		data[b], data[a]
    return data


if __name__ == "__main__":
  UpperCAmelCase_   : Dict   			= [0, 1, 2, 3, 4, 5, 6, 7]
  UpperCAmelCase_   : Dict   			= ["""python""", """says""", """hello""", """!"""]
  print("""Fisher-Yates Shuffle:""")
  print("""List""", integers, strings)
  print("""FY Shuffle""", fisher_yates_shuffle(integers), fisher_yates_shuffle(strings))


