



from __future__ import annotations

import math
import random





def     __lowerCamelCase							(   __magic_name__						:	int  ,			__magic_name__						:	int  ,			__magic_name__						:	int    ):
							a__:							Optional[Any]									=d * e - 1
							a__:							Dict									=0
							a__:							int									=0
							while p == 0:
														a__:							str									=random.randint(2  ,			n - 1    )
														a__:							Optional[int]									=k
														while True:
																					if t % 2 == 0:
																												a__:							Union[str, Any]									=t // 2
																												a__:							List[str]									=(g**t) % n
																												a__:							Union[str, Any]									=math.gcd(x - 1  ,			__magic_name__    )
																												if x > 1 and y > 1:
																																			a__:							str									=y
																																			a__:							int									=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()










from __future__ import annotations





def     __lowerCamelCase							(   __magic_name__						:	int    ):
							for r in range(1  ,			__magic_name__    ):
														a__:							List[str]									=[]
														for x in range(n - 1    ):
																					a__:							int									=pow(__magic_name__  ,			__magic_name__  ,			__magic_name__    )
																					if val in li:
																												break
																					li.append(__magic_name__    )
														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)





