




from __future__ import annotations

__SCREAMING_SNAKE_CASE 						=list[tuple[int, int]]

__SCREAMING_SNAKE_CASE 						=[
    [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],
]

__SCREAMING_SNAKE_CASE 						=([-1, 0], [0, -1], [1, 0], [0, 1])  # up, left, down, right






class  __magic_name__						:
				'''simple docstring'''







				def __init__(							self:   Optional[int]		,					_lowerCamelCase:   int		,					_lowerCamelCase:   int		,					_lowerCamelCase:   int		,					_lowerCamelCase:   int		,					_lowerCamelCase:   float		,					_lowerCamelCase:   Node | None		,					):
											SCREAMING_SNAKE_CASE_   	=    pos_x
											SCREAMING_SNAKE_CASE_   	=    pos_y
											SCREAMING_SNAKE_CASE_   	=    (pos_y, pos_x)
											SCREAMING_SNAKE_CASE_   	=    goal_x
											SCREAMING_SNAKE_CASE_   	=    goal_y
											SCREAMING_SNAKE_CASE_   	=    g_cost
											SCREAMING_SNAKE_CASE_   	=    parent
											SCREAMING_SNAKE_CASE_   	=    self.calculate_heuristic()


				def     _A							(							self:   List[Any]		):
											SCREAMING_SNAKE_CASE_   	=    abs(self.pos_x - self.goal_x		)
											SCREAMING_SNAKE_CASE_   	=    abs(self.pos_y - self.goal_y		)
											return dx + dy





				def __lt__(							self:   Union[str, Any]		,					_lowerCamelCase:   Dict		):
											return self.f_cost < other.f_cost






class  __magic_name__						:
				'''simple docstring'''







				def __init__(							self:   List[str]		,					_lowerCamelCase:   tuple[int, int]		,					_lowerCamelCase:   tuple[int, int]		):
											SCREAMING_SNAKE_CASE_   	=    Node(start[1]		,					start[0]		,					goal[1]		,					goal[0]		,					0		,					_lowerCamelCase		)
											SCREAMING_SNAKE_CASE_   	=    Node(goal[1]		,					goal[0]		,					goal[1]		,					goal[0]		,					9_99_99		,					_lowerCamelCase		)

											SCREAMING_SNAKE_CASE_   	=    [self.start]
											SCREAMING_SNAKE_CASE_   	=    []

											SCREAMING_SNAKE_CASE_   	=    False


				def     _A							(							self:   List[str]		):
											while self.open_nodes:
																		# Open Nodes are sorted using __lt__
																		self.open_nodes.sort()
																		SCREAMING_SNAKE_CASE_   	=    self.open_nodes.pop(0		)

																		if current_node.pos == self.target.pos:
																									SCREAMING_SNAKE_CASE_   	=    True
																									return self.retrace_path(_lowerCamelCase		)

																		self.closed_nodes.append(_lowerCamelCase		)
																		SCREAMING_SNAKE_CASE_   	=    self.get_successors(_lowerCamelCase		)

																		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(_lowerCamelCase		)
																									else:
																																# retrieve the best current path
																																SCREAMING_SNAKE_CASE_   	=    self.open_nodes.pop(self.open_nodes.index(_lowerCamelCase		)		)

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

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


				def     _A							(							self:   str		,					_lowerCamelCase:   Node		):
											SCREAMING_SNAKE_CASE_   	=    []
											for action in delta:
																		SCREAMING_SNAKE_CASE_   	=    parent.pos_x + action[1]
																		SCREAMING_SNAKE_CASE_   	=    parent.pos_y + action[0]

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

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

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





				def     _A							(							self:   Optional[Any]		,					_lowerCamelCase:   Node | None		):
											SCREAMING_SNAKE_CASE_   	=    node
											SCREAMING_SNAKE_CASE_   	=    []
											while current_node is not None:
																		path.append((current_node.pos_y, current_node.pos_x)		)
																		SCREAMING_SNAKE_CASE_   	=    current_node.parent
											path.reverse()
											return path


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

			print("""------""")

			__SCREAMING_SNAKE_CASE 						=GreedyBestFirst(init, goal)
			__SCREAMING_SNAKE_CASE 						=greedy_bf.search()
			if path:
						for pos_x, pos_y in path:
									__SCREAMING_SNAKE_CASE 						=2

						for elem in grid:
									print(elem)












import webbrowser
from sys import argv
from urllib.parse import parse_qs, quote

import requests
from bsa import BeautifulSoup
from fake_useragent import UserAgent

if __name__ == "__main__":
			__SCREAMING_SNAKE_CASE 						="""%20""".join(argv[1:]) if len(argv) > 1 else quote(str(input("""Search: """)))

			print("""Googling.....""")

			__SCREAMING_SNAKE_CASE 						=f"""https://www.google.com/search?q={query}&num=100"""

			__SCREAMING_SNAKE_CASE 						=requests.get(
			    url,
			    headers={"""User-Agent""": str(UserAgent().random)},
			)

			try:
						__SCREAMING_SNAKE_CASE 						=(
						    BeautifulSoup(res.text, """html.parser""")
						    .find("""div""", attrs={"""class""": """yuRUbf"""})
						    .find("""a""")
						    .get("""href""")
						)

			except AttributeError:
						__SCREAMING_SNAKE_CASE 						=parse_qs(
						    BeautifulSoup(res.text, """html.parser""")
						    .find("""div""", attrs={"""class""": """kCrYT"""})
						    .find("""a""")
						    .get("""href""")
						)["""url"""][0]

			webbrowser.open(link)


