





from __future__ import annotations

from PIL import Image

# Define the first generation of cells
# fmt: off
_SCREAMING_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 				SCREAMING_SNAKE_CASE__    (     __a ):
	return [int(__a ) for c in f"""{ruleset:08}"""[:8]]


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


def 				SCREAMING_SNAKE_CASE__    (     __a ):
	snake_case_		:      Tuple           =						Image.new('RGB' ,			(len(cells[0] ), len(__a )) )
	snake_case_		:      List[str]           =						img.load()
	# Generates image
	for w in range(img.width ):
		for h in range(img.height ):
			snake_case_		:      Optional[int]           =						2_55 - int(2_55 * cells[h][w] )
			snake_case_		:      int           =						(color, color, color)
	return img


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





"""simple docstring"""







from __future__ import annotations






def        a__			(							_UpperCamelCase			):





						"""simple docstring"""

						UpperCAmelCase__												=     sorted(_UpperCamelCase			)
						UpperCAmelCase__												=     len(_UpperCamelCase			)
						UpperCAmelCase__												=     length >> 1
						return (
						    (sorted_list[mid_index] + sorted_list[mid_index - 1]) / 2
						    if length % 2 == 0
						    else sorted_list[mid_index]
						)






def        a__			(							):





						"""simple docstring"""

						import doctest

						doctest.testmod()


if __name__ == "__main__":
						main()