



'''simple docstring'''




from collections import OrderedDict
from dataclasses import fields
from typing import Any, Tuple

import numpy as np

from .import_utils import is_torch_available



def  __lowerCamelCase    (   _lowercase						) ->     Dict:
							if is_torch_available():
														import torch

														if isinstance(_lowercase      ,							torch.Tensor						):
																					return True

							return isinstance(_lowercase      ,							np.ndarray						)


class      UpperCamelCase_					(				__magic_name__     ):





	def 					_lowercase(    self       )     ->     List[Any]:
								UpperCAmelCase	:						Optional[Any]					=						fields(self       )

								# Safety and consistency checks
								if not len(A       ):
															raise ValueError(f'''{self.__class__.__name__} has no fields.'''       )

								UpperCAmelCase	:						int					=						getattr(self						,						class_fields[0].name       )
								UpperCAmelCase	:						List[Any]					=						all(getattr(self						,						field.name       ) is None for field in class_fields[1:]       )

								if other_fields_are_none and isinstance(A						,						A       ):
															for key, value in first_field.items():
																						UpperCAmelCase	:						Optional[Any]					=						value
								else:
															for field in class_fields:
																						UpperCAmelCase	:						List[str]					=						getattr(self						,						field.name       )
																						if v is not None:
																													UpperCAmelCase	:						List[Any]					=						v





	def __delitem__(    self						,						*A						,						**A       )     ->     List[Any]:
								raise Exception(f'''You cannot use ``__delitem__`` on a {self.__class__.__name__} instance.'''       )





	def 					_lowercase(    self						,						*A						,						**A       )     ->     Union[str, Any]:
								raise Exception(f'''You cannot use ``setdefault`` on a {self.__class__.__name__} instance.'''       )





	def 					_lowercase(    self						,						*A						,						**A       )     ->     Dict:
								raise Exception(f'''You cannot use ``pop`` on a {self.__class__.__name__} instance.'''       )





	def 					_lowercase(    self						,						*A						,						**A       )     ->     Union[str, Any]:
								raise Exception(f'''You cannot use ``update`` on a {self.__class__.__name__} instance.'''       )





	def __getitem__(    self						,						A       )     ->     List[str]:
								if isinstance(A						,						A       ):
															UpperCAmelCase	:						List[str]					=						dict(self.items()       )
															return inner_dict[k]
								else:
															return self.to_tuple()[k]





	def __setattr__(    self						,						A						,						A       )     ->     Optional[Any]:
								if name in self.keys() and value is not None:
															# Don't call self.__setitem__ to avoid recursion errors
															super().__setitem__(A						,						A       )
								super().__setattr__(A						,						A       )





	def __setitem__(    self						,						A						,						A       )     ->     Tuple:
								# Will raise a KeyException if needed
								super().__setitem__(A						,						A       )
								# Don't call self.__setattr__ to avoid recursion errors
								super().__setattr__(A						,						A       )






	def 					_lowercase(    self       )     ->     Tuple[Any]:
								return tuple(self[k] for k in self.keys()       )






'''simple docstring'''




from __future__ import annotations



def  __lowerCamelCase    (   _lowercase						) ->     int | None:
							for r in range(1      ,							_lowercase						):
														UpperCAmelCase	:						Dict					=						[]
														for x in range(n - 1						):
																					UpperCAmelCase	:						List[str]					=						pow(_lowercase      ,							_lowercase      ,							_lowercase						)
																					if val in li:
																												break
																					li.append(_lowercase						)
														else:
																					return r
							return None


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

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

