'''simple docstring'''

import numpy as np


def 					UpperCAmelCase__      (							_lowerCAmelCase						: Union[str, Any])						->		Optional[Any]:



						"""simple docstring"""

						snake_case   :					Optional[Any]							=						a.shape
						snake_case   :					Tuple							=						min(_lowerCAmelCase,			_lowerCAmelCase)
						snake_case   :					Any							=						np.eye(_lowerCAmelCase)
						snake_case   :					Optional[Any]							=						a.copy()

						for k in range(t - 1):
												# select a column of modified matrix A':
												snake_case   :					List[str]							=						r[k:, [k]]
												# construct first basis vector
												snake_case   :					Any							=						np.zeros_like(_lowerCAmelCase)
												snake_case   :					Dict							=						1.0
												# determine scaling factor
												snake_case   :					Optional[int]							=						np.linalg.norm(_lowerCAmelCase)
												# construct vector v for Householder reflection
												snake_case   :					Tuple							=						x + np.sign(x[0]) * alpha * ea
												v /= np.linalg.norm(_lowerCAmelCase)

												# construct the Householder matrix
												snake_case   :					str							=						np.eye(m - k) - 2.0 * v @ v.T
												# pad with ones and zeros as necessary
												snake_case   :					int							=						np.block([[np.eye(_lowerCAmelCase), np.zeros((k, m - k))], [np.zeros((m - k, k)), q_k]])

												snake_case   :					Tuple							=						q @ q_k.T
												snake_case   :					Dict							=						q_k @ r

						return q, r


if __name__ == "__main__":
						import doctest

						doctest.testmod()






'''simple docstring'''

from __future__ import annotations


def 					UpperCAmelCase__      (							_lowerCAmelCase						: int)						->		int | None:



						"""simple docstring"""

						for r in range(1,			_lowerCAmelCase):
												snake_case   :					Optional[Any]							=						[]
												for x in range(n - 1):
																		snake_case   :					int							=						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)





