





from __future__ import annotations







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


if __name__ == "__main__":
				UpperCAmelCase						:       Optional[int]        =					int(input('''Enter a prime number q: '''))
				UpperCAmelCase						:       Optional[Any]        =					find_primitive(q)
				if a is None:
								print(F"""Cannot find the primitive for the value: {a!r}""")
				else:
								UpperCAmelCase						:       str        =					int(input('''Enter private key of A: '''))
								UpperCAmelCase						:       Dict        =					pow(a, a_private, q)
								UpperCAmelCase						:       List[Any]        =					int(input('''Enter private key of B: '''))
								UpperCAmelCase						:       Tuple        =					pow(a, b_private, q)

								UpperCAmelCase						:       int        =					pow(b_public, a_private, q)
								UpperCAmelCase						:       Union[str, Any]        =					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)











from __future__ import annotations

import math
import random







def 			_SCREAMING_SNAKE_CASE    (       a ,						a ,						a  )				->				list[int]:
					__A     :						int          =    d * e - 1
					__A     :						List[str]          =    0
					__A     :						Optional[Any]          =    0
					while p == 0:
										__A     :						List[Any]          =    random.randint(2 ,						n - 1  )
										__A     :						Optional[int]          =    k
										while True:
															if t % 2 == 0:
																				__A     :						Tuple          =    t // 2
																				__A     :						List[str]          =    (g**t) % n
																				__A     :						List[Any]          =    math.gcd(x - 1 ,						a  )
																				if x > 1 and y > 1:
																									__A     :						List[str]          =    y
																									__A     :						str          =    n // y
																									break  # find the correct factors
															else:
																				break  # t is not divisible by 2, break and choose another g
					return sorted([p, q]  )


if __name__ == "__main__":
				import doctest

				doctest.testmod()




