"""simple docstring"""






def     a_		(   lowerCamelCase   ,     lowerCamelCase   ,     lowerCamelCase   ,     lowerCamelCase			):
				UpperCAmelCase__			 =				int((lower_bound + upper_bound) // 2			)
				if array[r] == value:
								return r
				if lower_bound >= upper_bound:
								return -1
				if array[r] < value:
								return binary_search(lowerCamelCase   ,     r + 1   ,     lowerCamelCase   ,     lowerCamelCase			)
				else:
								return binary_search(lowerCamelCase   ,     lowerCamelCase   ,     r - 1   ,     lowerCamelCase			)



def     a_		(   lowerCamelCase   ,     lowerCamelCase			):
				UpperCAmelCase__			 =				0
				if matrix[index][0] == value:
								return [index, 0]
				while index < len(lowerCamelCase			) and matrix[index][0] < value:
								UpperCAmelCase__			 =				binary_search(matrix[index]   ,     0   ,     len(matrix[index]			) - 1   ,     lowerCamelCase			)
								if r != -1:
												return [index, r]
								index += 1
				return [-1, -1]


if __name__ == "__main__":
						import doctest

						doctest.testmod()




"""simple docstring"""






from __future__ import annotations



def     a_		(   lowerCamelCase			):
				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__":
						lowerCAmelCase__    :    Any			=      int(input('Enter a prime number q: '))
						lowerCAmelCase__    :    List[str]			=      find_primitive(q)
						if a is None:
												print(F"""Cannot find the primitive for the value: {a!r}""")
						else:
												lowerCAmelCase__    :    str			=      int(input('Enter private key of A: '))
												lowerCAmelCase__    :    List[Any]			=      pow(a, a_private, q)
												lowerCAmelCase__    :    List[str]			=      int(input('Enter private key of B: '))
												lowerCAmelCase__    :    Any			=      pow(a, b_private, q)

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



