"""simple docstring"""
from __future__ import annotations

from PIL import Image

# Define the first generation of cells
# fmt: off
lowercase__   			=      [[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1,
          0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]]







def 		__a  (      _SCREAMING_SNAKE_CASE  )      ->list[int]:
  return [int(_SCREAMING_SNAKE_CASE  ) for c in F'{ruleset:08}'[:8]]







def 		__a  (      _SCREAMING_SNAKE_CASE						,	_SCREAMING_SNAKE_CASE						,	_SCREAMING_SNAKE_CASE  )      ->list[int]:
  a__:	int     				=      len(cells[0]  )  # 31
  a__:	List[Any]     				=      []
  for i in range(_SCREAMING_SNAKE_CASE  ):
    # Get the neighbors of each cell
    # Handle neighbours outside bounds by using 0 as their value
    a__:	List[Any]     				=      0 if i == 0 else cells[time][i - 1]
    a__:	Dict     				=      0 if i == population - 1 else cells[time][i + 1]
    # Define a new cell and add it to the new generation
    a__:	str     				=      7 - int(F'{left_neighbor}{cells[time][i]}{right_neighbor}'						,	2  )
    next_generation.append(rule[situation]  )
  return next_generation







def 		__a  (      _SCREAMING_SNAKE_CASE  )      ->Image.Image:
  a__:	Optional[Any]     				=      Image.new('RGB'						,	(len(cells[0]  ), len(_SCREAMING_SNAKE_CASE  ))  )
  a__:	Any     				=      img.load()
  # Generates image
  for w in range(img.width  ):
    for h in range(img.height  ):
      a__:	Dict     				=      255 - int(255 * cells[h][w]  )
      a__:	Any     				=      (color, color, color)
  return img


if __name__ == "__main__":
 lowercase__   			=      bin(int(input('Rule:\n').strip()))[2:]
 lowercase__   			=      format_ruleset(int(rule_num))
 for time in range(16):
  CELLS.append(new_generation(CELLS, rule, time))
 lowercase__   			=      generate_image(CELLS)
 # Uncomment to save the image
 # img.save(f"rule_{rule_num}.png")
 img.show()



"""simple docstring"""
def 		__a  (      _SCREAMING_SNAKE_CASE = 100						,	_SCREAMING_SNAKE_CASE = 100  )      ->int:
  return max(
      sum(int(_SCREAMING_SNAKE_CASE  ) for x in str(base**power  )  )
      for base in range(_SCREAMING_SNAKE_CASE  )
      for power in range(_SCREAMING_SNAKE_CASE  )  )


# Tests
if __name__ == "__main__":
 import doctest

 doctest.testmod()


