



def        __a     (    lowerCAmelCase_   :					int			,lowerCAmelCase_   :					int = 10_00				)      -> str:






						'''simple docstring'''



						if (not isinstance(lowerCAmelCase_			,lowerCAmelCase_				)) or (digit_position <= 0):
												raise ValueError("""Digit position must be a positive integer"""				)
						elif (not isinstance(lowerCAmelCase_			,lowerCAmelCase_				)) or (precision < 0):
												raise ValueError("""Precision must be a nonnegative integer"""				)

						# compute an approximation of (16 ** (n - 1)) * pi whose fractional part is mostly
						# accurate
						UpperCAmelCase_=   (
						    4 * _subsum(lowerCAmelCase_			,1			,lowerCAmelCase_				)
						    - 2 * _subsum(lowerCAmelCase_			,4			,lowerCAmelCase_				)
						    - _subsum(lowerCAmelCase_			,5			,lowerCAmelCase_				)
						    - _subsum(lowerCAmelCase_			,6			,lowerCAmelCase_				)
						)

						# return the first hex digit of the fractional part of the result
						return hex(int((sum_result % 1) * 16				)				)[2:]



def        __a     (    lowerCAmelCase_   :					int			,lowerCAmelCase_   :					int			,lowerCAmelCase_   :					int				)      -> float:






						'''simple docstring'''



						UpperCAmelCase_=   0.0
						for sum_index in range(digit_pos_to_extract + precision				):
												UpperCAmelCase_=   8 * sum_index + denominator_addend
												if sum_index < digit_pos_to_extract:
																		# if the exponential term is an integer and we mod it by the denominator
																		# before dividing, only the integer part of the sum will change;
																		# the fractional part will not
																		UpperCAmelCase_=   pow(
																		    16			,digit_pos_to_extract - 1 - sum_index			,lowerCAmelCase_				)
												else:
																		UpperCAmelCase_=   pow(16			,digit_pos_to_extract - 1 - sum_index				)
												total += exponential_term / denominator
						return total


if __name__ == "__main__":
	import doctest

	doctest.testmod()









from __future__ import annotations



def        __a     (    lowerCAmelCase_   :					int				)      -> int | None:






						'''simple docstring'''



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


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

		__A				    =						pow(b_public, a_private, q)
		__A				    =						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)




