

from __future__ import annotations

import sys





def    _snake_case		(snake_case_				:    int						,					snake_case_				:    int     )       ->		tuple[int, int]:
  # base cases
  if abs(a_     ) == 1:
    return a, 0
  elif abs(a_     ) == 1:
    return 0, b

  __UpperCAmelCase, __UpperCAmelCase  :     Union[str, Any]		=    a, b
  __UpperCAmelCase, __UpperCAmelCase  :     List[str]		=    1, 0
  __UpperCAmelCase, __UpperCAmelCase  :     Tuple		=    0, 1

  while remainder != 0:
    __UpperCAmelCase  :     List[str]		=    old_remainder // remainder
    __UpperCAmelCase, __UpperCAmelCase  :     List[Any]		=    remainder, old_remainder - quotient * remainder
    __UpperCAmelCase, __UpperCAmelCase  :     int		=    coeff_a, old_coeff_a - quotient * coeff_a
    __UpperCAmelCase, __UpperCAmelCase  :     Optional[int]		=    coeff_b, old_coeff_b - quotient * coeff_b

  # sign correction for negative numbers
  if a < 0:
    __UpperCAmelCase  :     str		=    -old_coeff_a
  if b < 0:
    __UpperCAmelCase  :     Dict		=    -old_coeff_b

  return old_coeff_a, old_coeff_b





def    _snake_case		()       ->		Tuple:
  if len(sys.argv     ) < 3:
    print('2 integer arguments required'     )
    return 1
  __UpperCAmelCase  :     Optional[int]		=    int(sys.argv[1]     )
  __UpperCAmelCase  :     str		=    int(sys.argv[2]     )
  print(extended_euclidean_algorithm(a_						,					a_     )     )
  return 0


if __name__ == "__main__":
      raise SystemExit(main())








def    _snake_case		(snake_case_				:    int						,					snake_case_				:    int						,					snake_case_				:    int						,					snake_case_				:    int     )       ->		int:
  return len_board * len_board_column * row + column





def    _snake_case		(snake_case_				:    list[list[str]]						,					snake_case_				:    str						,					snake_case_				:    int						,					snake_case_				:    int						,					snake_case_				:    int						,					snake_case_				:    set[int]						,					)       ->		bool:

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

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

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

    __UpperCAmelCase  :     str		=    get_point_key(snake_case_						,					snake_case_						,					snake_case_						,					snake_case_     )
    if key in visited_points_set:
      continue

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

    visited_points_set.remove(snake_case_     )

  return False





def    _snake_case		(snake_case_				:    list[list[str]]						,					snake_case_				:    str     )       ->		bool:
  __UpperCAmelCase  :     str		=    (
      'The board should be a non empty matrix of single chars strings.'
  )

  __UpperCAmelCase  :     Any		=    len(snake_case_     )
  if not isinstance(snake_case_						,					snake_case_     ) or len(snake_case_     ) == 0:
    raise ValueError(snake_case_     )

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

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

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

  __UpperCAmelCase  :     str		=    len(board[0]     )
  for i in range(snake_case_     ):
    for j in range(snake_case_     ):
      if exits_word(
          snake_case_						,					snake_case_						,					snake_case_						,					snake_case_						,					0						,					{get_point_key(snake_case_						,					snake_case_						,					snake_case_						,					snake_case_     )}     ):
        return True

  return False


if __name__ == "__main__":
      import doctest

      doctest.testmod()





