



from __future__ import annotations

from PIL import Image

# Define the first generation of cells
# fmt: off
UpperCAmelCase							=       [[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_   (						__a  :					int		):

				"""simple docstring"""
				return [int(__a		) for c in F'''{ruleset:08}'''[:8]]

def       A_   (						__a  :					list[list[int]]			,		__a  :					list[int]			,		__a  :					int		):

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

def       A_   (						__a  :					list[list[int]]		):

				"""simple docstring"""
				a__					   =		Image.new("""RGB"""			,		(len(cells[0]		), len(__a		))		)
				a__					   =		img.load()
				# Generates image
				for w in range(img.width		):
								for h in range(img.height		):
												a__					   =		255 - int(255 * cells[h][w]		)
												a__					   =		(color, color, color)
				return img


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






from math import gcd

def       A_   (						__a  :					int = 12_000		):

				"""simple docstring"""
				a__					   =		0
				for d in range(max_d + 1		):
								for n in range(d // 3 + 1			,		(d + 1) // 2		):
												if gcd(__a			,		__a		) == 1:
																fractions_number += 1
				return fractions_number


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

