"""simple docstring"""
from __future__ import annotations

from PIL import Image

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







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







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


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









from __future__ import annotations




def 			lowerCAmelCase_			(				UpperCamelCase_	)  ->		int | None:
       for r in range(1       ,		UpperCamelCase_	):
              UpperCamelCase_ 							=	[]
              for x in range(n - 1	):
                     UpperCamelCase_ 							=	pow(UpperCamelCase_       ,		UpperCamelCase_       ,		UpperCamelCase_	)
                     if val in li:
                            break
                     li.append(UpperCamelCase_	)
              else:
                     return r
       return None


if __name__ == "__main__":
     _UpperCAmelCase										=					int(input('Enter a prime number q: '))
     _UpperCAmelCase										=					find_primitive(q)
     if a is None:
          print(f'''Cannot find the primitive for the value: {a!r}''')
     else:
          _UpperCAmelCase										=					int(input('Enter private key of A: '))
          _UpperCAmelCase										=					pow(a, a_private, q)
          _UpperCAmelCase										=					int(input('Enter private key of B: '))
          _UpperCAmelCase										=					pow(a, b_private, q)

          _UpperCAmelCase										=					pow(b_public, a_private, q)
          _UpperCAmelCase										=					pow(a_public, b_private, q)

          print('The key value generated by A is: ', a_secret)
          print('The key value generated by B is: ', b_secret)

