






"""simple docstring"""



class 			a	:







    def __init__(     self				,						_lowerCamelCase=None			):
      lowercase				       =			data
      lowercase				       =			None







    def __repr__(     self			):
      lowercase				       =			''
      lowercase				       =			self
      while temp:
        string_rep += F'<{temp.data}> ---> '
        lowercase				       =			temp.next
      string_rep += "<END>"
      return string_rep


def 		_SCREAMING_SNAKE_CASE					(       __snake_case     :    Tuple       ):





  '''simple docstring'''





  if not elements_list:
    raise Exception('The Elements List is empty'       )

  # Set first element as Head
  lowercase				       =			Node(elements_list[0]       )
  lowercase				       =			head
  # Loop through elements from position 1
  for data in elements_list[1:]:
    lowercase				       =			Node(__snake_case       )
    lowercase				       =			current.next
  return head


_UpperCamelCase						:    Optional[Any]		=						[1, 3, 5, 3_2, 4_4, 1_2, 4_3]
print(F'''List: {list_data}''')
print('Creating Linked List from List.')
_UpperCamelCase						:    str		=						make_linked_list(list_data)
print('Linked List:')



print(linked_list)






from __future__ import annotations

from PIL import Image

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



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



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


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