






'''simple docstring'''

from __future__ import annotations
def      __lowercase	(_lowercase,    _lowercase  ) ->  list[tuple[int, int]]:


     """simple docstring"""
     __lowerCamelCase    :							List[Any]					 =					position
     __lowerCamelCase    :							Dict					 =					[
         (y + 1, x + 2),
         (y - 1, x + 2),
         (y + 1, x - 2),
         (y - 1, x - 2),
         (y + 2, x + 1),
         (y + 2, x - 1),
         (y - 2, x + 1),
         (y - 2, x - 1),
     ]
     __lowerCamelCase    :							Optional[Any]					 =					[]

     for position in positions:
          __lowerCamelCase    :							Any					 =					position
          if 0 <= y_test < n and 0 <= x_test < n:
               permissible_positions.append(snake_case__  )

     return permissible_positions
def      __lowercase	(_lowercase  ) ->  bool:


     """simple docstring"""
     return not any(elem == 0 for row in board for elem in row  )
def      __lowercase	(_lowercase,    _lowercase,    _lowercase  ) ->  bool:


     """simple docstring"""

     if is_complete(snake_case__  ):
          return True

     for position in get_valid_pos(snake_case__,    len(snake_case__  )  ):
          __lowerCamelCase    :							Tuple					 =					position

          if board[y][x] == 0:
               __lowerCamelCase    :							List[Any]					 =					curr + 1
               if open_knight_tour_helper(snake_case__,    snake_case__,    curr + 1  ):
                    return True
               __lowerCamelCase    :							int					 =					0

     return False
def      __lowercase	(_lowercase  ) ->  list[list[int]]:


     """simple docstring"""
     __lowerCamelCase    :							Union[str, Any]					 =					[[0 for i in range(snake_case__  )] for j in range(snake_case__  )]

     for i in range(snake_case__  ):
          for j in range(snake_case__  ):
               __lowerCamelCase    :							List[str]					 =					1
               if open_knight_tour_helper(snake_case__,    (i, j),    1  ):
                    return board
               __lowerCamelCase    :							Tuple					 =					0

     __lowerCamelCase    :							Optional[int]					 =					f"Open Kight Tour cannot be performed on a board of size {n}"
     raise ValueError(snake_case__  )


if __name__ == "__main__":
   import doctest

   doctest.testmod()







"""simple docstring"""






import os





def 				A_       ( )					->  Any:
			with open(os.path.dirname(snake_case__		) + '''/p022_names.txt'''		) as file:
						_UpperCamelCase					:Optional[Any]					     =	str(file.readlines()[0]		)
						_UpperCamelCase					:Dict					     =	names.replace('''"'''       ,					''''''		).split(''','''		)

			names.sort()

			_UpperCamelCase					:str					     =	0
			_UpperCamelCase					:Union[str, Any]					     =	0

			for i, name in enumerate(snake_case__		):
						for letter in name:
									name_score += ord(snake_case__		) - 64

						total_score += (i + 1) * name_score
						_UpperCamelCase					:List[Any]					     =	0
			return total_score


if __name__ == "__main__":
					print(solution())

