

import sys

sys.set_int_max_str_digits(0)  # type: ignore


def  __lowerCamelCase      (				SCREAMING_SNAKE_CASE_					:     int   )							->       bool:
      """simple docstring"""

      SCREAMING_SNAKE_CASE_				:      List[Any]					=	[0] * 1_1
      SCREAMING_SNAKE_CASE_				:      Optional[int]					=	[0] * 1_1

      # mark last 9 numbers
      for _ in range(9   ):
            SCREAMING_SNAKE_CASE_				:      List[str]					=	1
            SCREAMING_SNAKE_CASE_				:      Dict					=	number // 1_0
      # flag
      SCREAMING_SNAKE_CASE_				:      int					=	True

      # check last 9 numbers for pandigitality

      for x in range(9   ):
            if not check_last[x + 1]:
                  SCREAMING_SNAKE_CASE_				:      List[str]					=	False
      if not f:
            return f

      # mark first 9 numbers
      SCREAMING_SNAKE_CASE_				:      Optional[Any]					=	int(str(SCREAMING_SNAKE_CASE_   )[:9]   )

      for _ in range(9   ):
            SCREAMING_SNAKE_CASE_				:      str					=	1
            SCREAMING_SNAKE_CASE_				:      str					=	number // 1_0

      # check first 9 numbers for pandigitality

      for x in range(9   ):
            if not check_front[x + 1]:
                  SCREAMING_SNAKE_CASE_				:      Optional[int]					=	False
      return f


def  __lowerCamelCase      (				SCREAMING_SNAKE_CASE_					:     int   )							->       bool:
      """simple docstring"""

      SCREAMING_SNAKE_CASE_				:      Any					=	[0] * 1_1

      # mark last 9 numbers
      for _ in range(9   ):
            SCREAMING_SNAKE_CASE_				:      str					=	1
            SCREAMING_SNAKE_CASE_				:      str					=	number // 1_0
      # flag
      SCREAMING_SNAKE_CASE_				:      Tuple					=	True

      # check last 9 numbers for pandigitality

      for x in range(9   ):
            if not check_last[x + 1]:
                  SCREAMING_SNAKE_CASE_				:      Optional[int]					=	False
      return f


def  __lowerCamelCase      (				)							->       int:
      """simple docstring"""

      SCREAMING_SNAKE_CASE_				:      Dict					=	1
      SCREAMING_SNAKE_CASE_				:      Any					=	1
      SCREAMING_SNAKE_CASE_				:      Tuple					=	2
      # temporary Fibonacci numbers

      SCREAMING_SNAKE_CASE_				:      Any					=	1
      SCREAMING_SNAKE_CASE_				:      int					=	1
      SCREAMING_SNAKE_CASE_				:      Tuple					=	2
      # temporary Fibonacci numbers mod 1e9

      # mod m=1e9, done for fast optimisation
      SCREAMING_SNAKE_CASE_				:      int					=	[0] * 1_0_0_0_0_0_0
      SCREAMING_SNAKE_CASE_				:      List[str]					=	1_0_0_0_0_0_0_0_0_0

      for x in range(1_0_0_0_0_0_0   ):
            SCREAMING_SNAKE_CASE_				:      Tuple					=	(aa + ba) % m
            SCREAMING_SNAKE_CASE_				:      Tuple					=	ba % m
            SCREAMING_SNAKE_CASE_				:      int					=	ca % m
            if checka(SCREAMING_SNAKE_CASE_   ):
                  SCREAMING_SNAKE_CASE_				:      Any					=	1

      for x in range(1_0_0_0_0_0_0   ):
            SCREAMING_SNAKE_CASE_				:      List[str]					=	a + b
            SCREAMING_SNAKE_CASE_				:      Dict					=	b
            SCREAMING_SNAKE_CASE_				:      int					=	c
            # perform check only if in tocheck
            if tocheck[x + 3] and check(SCREAMING_SNAKE_CASE_   ):
                  return x + 3  # first 2 already done
      return -1


if __name__ == "__main__":
      print(F'''{solution() = }''')




'''simple docstring'''






from __future__ import annotations

from PIL import Image

# Define the first generation of cells
# fmt: off
snake_case_					  =	[[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  __lowerCamelCase      (				SCREAMING_SNAKE_CASE_					:     int   )							->       list[int]:
      """simple docstring"""

      return [int(SCREAMING_SNAKE_CASE_   ) for c in F"{ruleset:08}"[:8]]


def  __lowerCamelCase      (				SCREAMING_SNAKE_CASE_					:     list[list[int]]  ,  SCREAMING_SNAKE_CASE_					:     list[int]  ,  SCREAMING_SNAKE_CASE_					:     int   )							->       list[int]:
      """simple docstring"""

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


def  __lowerCamelCase      (				SCREAMING_SNAKE_CASE_					:     list[list[int]]   )							->       Image.Image:
      """simple docstring"""

      SCREAMING_SNAKE_CASE_				:      Tuple					=	Image.new("RGB"  ,  (len(cells[0]   ), len(SCREAMING_SNAKE_CASE_   ))   )
      SCREAMING_SNAKE_CASE_				:      Optional[int]					=	img.load()
      # Generates image
      for w in range(img.width   ):
            for h in range(img.height   ):
                  SCREAMING_SNAKE_CASE_				:      List[Any]					=	2_5_5 - int(2_5_5 * cells[h][w]   )
                  SCREAMING_SNAKE_CASE_				:      Optional[int]					=	(color, color, color)
      return img


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

