





'''simple docstring'''






def    lowercase_   (		lowercase__					,	lowercase__					,	lowercase__					,	lowercase__    ) ->int:
						return len_board * len_board_column * row + column





def    lowercase_   (		lowercase__					,	lowercase__					,	lowercase__					,	lowercase__					,	lowercase__					,	lowercase__					,	) ->bool:

						if board[row][column] != word[word_index]:
												return False

						if word_index == len(a_    ) - 1:
												return True

						_snake_case: int	       =		[(0, 1), (0, -1), (-1, 0), (1, 0)]
						_snake_case: List[Any]	       =		len(a_    )
						_snake_case: str	       =		len(board[0]    )
						for direction in traverts_directions:
												_snake_case: Optional[int]	       =		row + direction[0]
												_snake_case: Union[str, Any]	       =		column + direction[1]
												if not (0 <= next_i < len_board and 0 <= next_j < len_board_column):
																		continue

												_snake_case: Union[str, Any]	       =		get_point_key(a_					,	a_					,	a_					,	a_    )
												if key in visited_points_set:
																		continue

												visited_points_set.add(a_    )
												if exits_word(a_					,	a_					,	a_					,	a_					,	word_index + 1					,	a_    ):
																		return True

												visited_points_set.remove(a_    )

						return False





def    lowercase_   (		lowercase__					,	lowercase__    ) ->bool:
						_snake_case: Dict	       =		(
						    'The board should be a non empty matrix of single chars strings.'
						)

						_snake_case: Optional[Any]	       =		len(a_    )
						if not isinstance(a_					,	a_    ) or len(a_    ) == 0:
												raise ValueError(a_    )

						for row in board:
												if not isinstance(a_					,	a_    ) or len(a_    ) == 0:
																		raise ValueError(a_    )

												for item in row:
																		if not isinstance(a_					,	a_    ) or len(a_    ) != 1:
																								raise ValueError(a_    )

    # Validate word
						if not isinstance(a_					,	a_    ) or len(a_    ) == 0:
												raise ValueError(
												    'The word parameter should be a string of length greater than 0.'    )

						_snake_case: Dict	       =		len(board[0]    )
						for i in range(a_    ):
												for j in range(a_    ):
																		if exits_word(
																		    a_					,	a_					,	a_					,	a_					,	0					,	{get_point_key(a_					,	a_					,	a_					,	a_    )}    ):
																								return True

						return False


if __name__ == "__main__":
		import doctest

		doctest.testmod()







"""simple docstring"""







def       __UpperCAmelCase		(		a_      :		list[list[int]]					)  ->							bool:
   # must be
   _UpperCAmelCase 						=       [list(a_					) for row in matrix]
   if matrix and isinstance(a_     ,	a_					):
      if isinstance(matrix[0]     ,	a_					):
         _UpperCAmelCase 						=       0
         for row in matrix:
            if prev_len == 0:
               _UpperCAmelCase 						=       len(a_					)
               _UpperCAmelCase 						=       True
            else:
               _UpperCAmelCase 						=       prev_len == len(a_					)
      else:
         _UpperCAmelCase 						=       True
   else:
      _UpperCAmelCase 						=       False

   return result
def       __UpperCAmelCase		(		a_      :		list[list[int]]					)  ->							None:
   if check_matrix(a_					) and len(a_					) > 0:
      _UpperCAmelCase 						=       [list(a_					) for row in a]
      _UpperCAmelCase 						=       len(a_					)
      if isinstance(a[0]     ,	a_					):
         _UpperCAmelCase 						=       len(a[0]					)
      else:
         for dat in a:
            print(a_					)
         return

      # horizotal printing increasing
      for i in range(0     ,	a_					):
         print(a[0][i]					)
      # vertical printing down
      for i in range(1     ,	a_					):
         print(a[i][mat_col - 1]					)
      # horizotal printing decreasing
      if mat_row > 1:
         for i in range(mat_col - 2     ,	-1     ,	-1					):
            print(a[mat_row - 1][i]					)
        # vertical printing up
      for i in range(mat_row - 2     ,	0     ,	-1					):
         print(a[i][0]					)
      _UpperCAmelCase 						=       [row[1 : mat_col - 1] for row in a[1 : mat_row - 1]]
      if len(a_					) > 0:
         spiral_print_clockwise(a_					)
      else:
         return
   else:
      print("Not a valid matrix"					)
      return
def       __UpperCAmelCase		(		a_      :		list[list]					)  ->							list[int]:
   if matrix:
      return list(matrix.pop(0					)					) + spiral_traversal(list(zip(*a_					)					)[::-1]					)
   else:
      return []


# driver code
if __name__ == "__main__":
  import doctest

  doctest.testmod()

  SCREAMING_SNAKE_CASE_  					= [[1, 2, 3, 4], [5, 6, 7, 8], [9, 10, 11, 12]]
  spiral_print_clockwise(a)

