





def      SCREAMING_SNAKE_CASE      (   lowerCAmelCase       ):

       if not isinstance(lowerCAmelCase     ,							lowerCAmelCase       ):
              raise ValueError('''Input series is not valid, valid series - [2, 4, 8]'''       )
       if len(lowerCAmelCase       ) == 0:
              raise ValueError('''Input list must be a non empty list'''       )
       if len(lowerCAmelCase       ) == 1:
              return True
       try:
              _UpperCamelCase														=    series[1] / series[0]
              for index in range(len(lowerCAmelCase       ) - 1       ):
                     if series[index + 1] / series[index] != common_ratio:
                            return False
       except ZeroDivisionError:
              return False
       return True


def      SCREAMING_SNAKE_CASE      (   lowerCAmelCase       ):

       if not isinstance(lowerCAmelCase     ,							lowerCAmelCase       ):
              raise ValueError('''Input series is not valid, valid series - [2, 4, 8]'''       )
       if len(lowerCAmelCase       ) == 0:
              raise ValueError('''Input list must be a non empty list'''       )
       _UpperCamelCase														=    1
       for value in series:
              answer *= value
       return pow(lowerCAmelCase     ,							1 / len(lowerCAmelCase       )       )


if __name__ == "__main__":
       import doctest

       doctest.testmod()














"""simple docstring"""





from __future__ import annotations

from PIL import Image

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

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







def 	lowerCAmelCase_(			SCREAMING_SNAKE_CASE			,						SCREAMING_SNAKE_CASE			,						SCREAMING_SNAKE_CASE       )       ->						list[int]:
    """simple docstring"""

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







def 	lowerCAmelCase_(			SCREAMING_SNAKE_CASE       )       ->						Image.Image:
    """simple docstring"""

    UpperCamelCase__								=     Image.new('RGB'			,						(len(cells[0]       ), len(SCREAMING_SNAKE_CASE       ))       )
    UpperCamelCase__								=     img.load()
    # Generates image
    for w in range(img.width       ):
        for h in range(img.height       ):
            UpperCamelCase__								=     2_55 - int(2_55 * cells[h][w]       )
            UpperCamelCase__								=     (color, color, color)
    return img


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




