

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__":
 _UpperCamelCase					     =						"""%20""".join(argv[1:]) if len(argv) > 1 else quote(str(input("Search: ")))

 print("Googling.....")

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

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

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

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

 webbrowser.open(link)








from __future__ import annotations
def 		a_							( __lowerCAmelCase   , __lowerCAmelCase = None				):
  lowerCAmelCase__										=      word_bank or []
  # create a table
  lowerCAmelCase__										=      len(__lowerCAmelCase				) + 1

  lowerCAmelCase__										=      []
  for _ in range(__lowerCAmelCase				):
    table.append([]				)
  # seed value
  lowerCAmelCase__										=      [[]]  # because empty string has empty combination

  # iterate through the indices
  for i in range(__lowerCAmelCase				):
    # condition
    if table[i] != []:
      for word in word_bank:
        # slice condition
        if target[i : i + len(__lowerCAmelCase				)] == word:
          lowerCAmelCase__										=      [
              [word, *way] for way in table[i]
          ]
          # adds the word to every combination the current position holds
          # now,push that combination to the table[i+len(word)]
          table[i + len(__lowerCAmelCase				)] += new_combinations

    # combinations are in reverse order so reverse for better output
  for combination in table[len(__lowerCAmelCase				)]:
    combination.reverse()

  return table[len(__lowerCAmelCase				)]


if __name__ == "__main__":
      print(all_construct("""jwajalapa""", ["""jwa""", """j""", """w""", """a""", """la""", """lapa"""]))
      print(all_construct("""rajamati""", ["""s""", """raj""", """amat""", """raja""", """ma""", """i""", """t"""]))
      print(
          all_construct(
              """hexagonosaurus""",
              ["""h""", """ex""", """hex""", """ag""", """ago""", """ru""", """auru""", """rus""", """go""", """no""", """o""", """s"""],
          )
      )

