
def 			_SCREAMING_SNAKE_CASE      (	_lowerCamelCase				:    int)      ->					int:






							'''simple docstring'''





							__UpperCamelCase			:     Any         =      1
							for i in range(1		,						num + 1):
														fact *= i
							return fact




def 			_SCREAMING_SNAKE_CASE      (	_lowerCamelCase				:    int)      ->					int:






							'''simple docstring'''





							__UpperCamelCase			:     Optional[int]         =      0
							while number > 0:
														__UpperCamelCase			:     str         =      number % 10
														sum_of_digits += last_digit
														__UpperCamelCase			:     str         =      number // 10  # Removing the last_digit from the given number
							return sum_of_digits




def 			_SCREAMING_SNAKE_CASE      (	_lowerCamelCase				:    int = 100)      ->					int:






							'''simple docstring'''





							__UpperCamelCase			:     int         =      factorial(_lowerCamelCase)
							__UpperCamelCase			:     Optional[int]         =      split_and_add(_lowerCamelCase)
							return result


if __name__ == "__main__":
		print(solution(int(input('Enter the Number: ').strip())))

from __future__ import annotations

lowercase						:      str									= list[tuple[int, int]]

lowercase						:      Optional[int]									= [
    [0, 0, 0, 0, 0, 0, 0],
    [0, 1, 0, 0, 0, 0, 0],  # 0 are free path whereas 1's are obstacles
    [0, 0, 0, 0, 0, 0, 0],
    [0, 0, 1, 0, 0, 0, 0],
    [1, 0, 1, 0, 0, 0, 0],
    [0, 0, 0, 0, 0, 0, 0],
    [0, 0, 0, 0, 1, 0, 0],
]

lowercase						:      int									= ([-1, 0], [0, -1], [1, 0], [0, 1])  # up, left, down, right




class 				lowerCamelCase__							:




	'''simple docstring'''




	def __init__(      self	:Optional[int]  ,     a	:int  ,     a	:int  ,     a	:int  ,     a	:int  ,     a	:float  ,     a	:Node | None  ,     )	->				List[Any]:
								__UpperCamelCase			:     List[Any]         =      pos_x
								__UpperCamelCase			:     List[str]         =      pos_y
								__UpperCamelCase			:     str         =      (pos_y, pos_x)
								__UpperCamelCase			:     Optional[int]         =      goal_x
								__UpperCamelCase			:     str         =      goal_y
								__UpperCamelCase			:     int         =      g_cost
								__UpperCamelCase			:     Dict         =      parent
								__UpperCamelCase			:     str         =      self.calculate_heuristic()







	def      _lowerCamelCase       (      self	:List[Any]		)	->				float:
								__UpperCamelCase			:     Any         =      abs(self.pos_x - self.goal_x		)
								__UpperCamelCase			:     Tuple         =      abs(self.pos_y - self.goal_y		)
								return dx + dy







	def __lt__(      self	:Union[str, Any]  ,     a	:Dict		)	->				bool:
								return self.f_cost < other.f_cost




class 				lowerCamelCase__							:




	'''simple docstring'''




	def __init__(      self	:List[str]  ,     a	:tuple[int, int]  ,     a	:tuple[int, int]		)	->				List[str]:
								__UpperCamelCase			:     Any         =      Node(start[1]  ,     start[0]  ,     goal[1]  ,     goal[0]  ,     0  ,     a		)
								__UpperCamelCase			:     List[str]         =      Node(goal[1]  ,     goal[0]  ,     goal[1]  ,     goal[0]  ,     9_9_9_9_9  ,     a		)

								__UpperCamelCase			:     Optional[int]         =      [self.start]
								__UpperCamelCase			:     list[Node]         =      []

								__UpperCamelCase			:     Any         =      False







	def      _lowerCamelCase       (      self	:List[str]		)	->				Path | None:
								while self.open_nodes:
															# Open Nodes are sorted using __lt__
															self.open_nodes.sort()
															__UpperCamelCase			:     Optional[int]         =      self.open_nodes.pop(0		)

															if current_node.pos == self.target.pos:
																						__UpperCamelCase			:     Dict         =      True
																						return self.retrace_path(a		)

															self.closed_nodes.append(a		)
															__UpperCamelCase			:     Union[str, Any]         =      self.get_successors(a		)

															for child_node in successors:
																						if child_node in self.closed_nodes:
																													continue

																						if child_node not in self.open_nodes:
																													self.open_nodes.append(a		)
																						else:
																													# retrieve the best current path
																													__UpperCamelCase			:     Union[str, Any]         =      self.open_nodes.pop(self.open_nodes.index(a		)		)

																													if child_node.g_cost < better_node.g_cost:
																																				self.open_nodes.append(a		)
																													else:
																																				self.open_nodes.append(a		)

								if not self.reached:
															return [self.start.pos]
								return None







	def      _lowerCamelCase       (      self	:str  ,     a	:Node		)	->				list[Node]:
								__UpperCamelCase			:     List[Any]         =      []
								for action in delta:
															__UpperCamelCase			:     Optional[Any]         =      parent.pos_x + action[1]
															__UpperCamelCase			:     List[Any]         =      parent.pos_y + action[0]

															if not (0 <= pos_x <= len(grid[0]		) - 1 and 0 <= pos_y <= len(a		) - 1):
																						continue

															if grid[pos_y][pos_x] != 0:
																						continue

															successors.append(
															    Node(
															        a  ,     a  ,     self.target.pos_y  ,     self.target.pos_x  ,     parent.g_cost + 1  ,     a  ,     )		)
								return successors







	def      _lowerCamelCase       (      self	:Optional[Any]  ,     a	:Node | None		)	->				Path:
								__UpperCamelCase			:     str         =      node
								__UpperCamelCase			:     int         =      []
								while current_node is not None:
															path.append((current_node.pos_y, current_node.pos_x)		)
															__UpperCamelCase			:     str         =      current_node.parent
								path.reverse()
								return path


if __name__ == "__main__":
		lowercase						:      List[str]									= (0, 0)
		lowercase						:      int									= (len(grid) - 1, len(grid[0]) - 1)
		for elem in grid:
				print(elem)

		print('------')

		lowercase						:      Any									= GreedyBestFirst(init, goal)
		lowercase						:      List[str]									= greedy_bf.search()
		if path:
				for pos_x, pos_y in path:
						lowercase						:      Optional[int]									= 2

				for elem in grid:
						print(elem)