"""simple docstring"""



import json
import os
import re
import sys
import urllib.request

import requests
from bsa import BeautifulSoup

SCREAMING_SNAKE_CASE__:Dict			=	{
    """User-Agent""": """Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36"""
    """ (KHTML, like Gecko) Chrome/70.0.3538.102 Safari/537.36 Edge/18.19582"""
}



def 					_lowerCamelCase(					a = "dhaka" ,  a = 5							):
       __a     				=  min(a ,  5_0							)  # Prevent abuse!
       __a     				=  {
           "q": query,
           "tbm": "isch",
           "hl": "en",
           "ijn": "0",
       }

       __a     				=  requests.get("https://www.google.com/search" ,  params=a ,  headers=a							)
       __a     				=  BeautifulSoup(html.text ,  "html.parser"							)
       __a     				=  "".join(
           re.findall(R"AF_initDataCallback\(([^<]+)\);" ,  str(soup.select("script"							)							)							)							)

       __a     				=  json.dumps(a							)
       __a     				=  json.loads(a							)

       __a     				=  re.findall(
           R"\[\"GRID_STATE0\",null,\[\[1,\[0,\".*?\",(.*),\"All\"," ,  a ,  )
       if not matched_google_image_data:
              return 0

       __a     				=  re.sub(
           R"\[\"(https\:\/\/encrypted-tbn0\.gstatic\.com\/images\?.*?)\",\d+,\d+\]" ,  "" ,  str(a							) ,  )

       __a     				=  re.findall(
           R"(?:'|,),\[\"(https:|http.*?)\",\d+,\d+\]" ,  a ,  )
       for index, fixed_full_res_image in enumerate(a							):
              if index >= max_images:
                     return index
              __a     				=  bytes(a ,  "ascii"							).decode(
                  "unicode-escape"							)
              __a     				=  bytes(a ,  "ascii"							).decode(
                  "unicode-escape"							)
              __a     				=  urllib.request.build_opener()
              __a     				=  [
                  (
                      "User-Agent",
                      "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36"
                      " (KHTML, like Gecko) Chrome/70.0.3538.102 Safari/537.36 Edge/18.19582",
                  )
              ]
              urllib.request.install_opener(a							)
              __a     				=  F"query_{query.replace(' ' ,  '_'							)}"
              if not os.path.exists(a							):
                     os.makedirs(a							)
              urllib.request.urlretrieve(  # noqa: S310
                  a ,  F"{path_name}/original_size_img_{index}.jpg"							)
       return index


if __name__ == "__main__":
   try:
      SCREAMING_SNAKE_CASE__:Dict			=	download_images_from_google_query(sys.argv[1])
      print(F'''{image_count} images were downloaded to disk.''')
   except IndexError:
      print("""Please provide a search term.""")
      raise

"""simple docstring"""



import os



def 					_lowerCamelCase(					):
       with open(os.path.dirname(a							) + "/grid.txt"							) as f:
              __a     				=  []  # noqa: E741
              for _ in range(2_0							):
                     l.append([int(a							) for x in f.readline().split()]							)

              __a     				=  0

              # right
              for i in range(2_0							):
                     for j in range(1_7							):
                            __a     				=  l[i][j] * l[i][j + 1] * l[i][j + 2] * l[i][j + 3]
                            if temp > maximum:
                                   __a     				=  temp

        # down
              for i in range(1_7							):
                     for j in range(2_0							):
                            __a     				=  l[i][j] * l[i + 1][j] * l[i + 2][j] * l[i + 3][j]
                            if temp > maximum:
                                   __a     				=  temp

        # diagonal 1
              for i in range(1_7							):
                     for j in range(1_7							):
                            __a     				=  l[i][j] * l[i + 1][j + 1] * l[i + 2][j + 2] * l[i + 3][j + 3]
                            if temp > maximum:
                                   __a     				=  temp

        # diagonal 2
              for i in range(1_7							):
                     for j in range(3 ,  2_0							):
                            __a     				=  l[i][j] * l[i + 1][j - 1] * l[i + 2][j - 2] * l[i + 3][j - 3]
                            if temp > maximum:
                                   __a     				=  temp
              return maximum


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