






"""simple docstring"""
from heapq import heappop, heappush

import numpy as np






def 			__UpperCamelCase	(		snake_case__   ,   snake_case__   ,   snake_case__   ,   snake_case__   ,   ):
	A_		:						Union[str, Any]	    =   grid.shape
	A_		:						Any	    =   [-1, 1, 0, 0]
	A_		:						Optional[Any]	    =   [0, 0, -1, 1]
	if allow_diagonal:
		dx += [-1, -1, 1, 1]
		dy += [-1, 1, -1, 1]

	A_		:						Tuple	    =   [(0, source)], set()
	A_		:						int	    =   np.full((rows, cols)   ,   np.inf					)
	A_		:						Optional[Any]	    =   0
	A_		:						Optional[int]	    =   np.empty((rows, cols)   ,   dtype=snake_case__					)
	A_		:						Union[str, Any]	    =   None

	while queue:
		(A_)		:						int	    =   heappop(snake_case__					)
		if (x, y) in visited:
			continue
		visited.add((x, y)					)

		if (x, y) == destination:
			A_		:						Tuple	    =   []
			while (x, y) != source:
				path.append((x, y)					)
				A_		:						str	    =   predecessors[x, y]
			path.append(snake_case__					)  # add the source manually
			path.reverse()
			return matrix[destination], path

		for i in range(len(snake_case__					)					):
			A_		:						List[str]	    =   x + dx[i], y + dy[i]
			if 0 <= nx < rows and 0 <= ny < cols:
				A_		:						List[Any]	    =   grid[nx][ny]
				if next_node == 1 and matrix[nx, ny] > dist + 1:
					heappush(snake_case__   ,   (dist + 1, (nx, ny))					)
					A_		:						List[str]	    =   dist + 1
					A_		:						Any	    =   (x, y)

	return np.inf, []


if __name__ == "__main__":
							import doctest

							doctest.testmod()









"""simple docstring"""
import sys
import webbrowser

import requests
from bsa import BeautifulSoup
from fake_useragent import UserAgent

if __name__ == "__main__":
							print("Googling.....")
							_lowerCAmelCase         =							"https://www.google.com/search?q=" + " ".join(sys.argv[1:])
							_lowerCAmelCase         =							requests.get(url, headers={"UserAgent": UserAgent().random})
							# res.raise_for_status()
							with open("project1a.html", "wb") as out_file:  # only for knowing the class
														for data in res.iter_content(10_000):
																					out_file.write(data)
							_lowerCAmelCase         =							BeautifulSoup(res.text, "html.parser")
							_lowerCAmelCase         =							list(soup.select(".eZt8xd"))[:5]

							print(len(links))
							for link in links:
														if link.text == "Maps":
																					webbrowser.open(link.get("href"))
														else:
																					webbrowser.open(F'https://google.com{link.get("href")}')

