

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  _snake_case		(snake_case_					:     Optional[Any]  )							->		Optional[Any]:
  if is_torch_available():
    import torch

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

  return isinstance(snake_case_    ,       np.ndarray  )







class      lowerCamelCase_ (			_lowerCAmelCase):




 def     a       (			self							):
   __UpperCAmelCase	:  Dict		=     fields(self							)

   # Safety and consistency checks
   if not len(_UpperCAmelCase							):
     raise ValueError(F"{self.__class__.__name__} has no fields."							)

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

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




 def __delitem__(			self  ,  *_UpperCAmelCase  ,  **_UpperCAmelCase							):
   raise Exception(F"You cannot use ``__delitem__`` on a {self.__class__.__name__} instance."							)




 def     a       (			self  ,  *_UpperCAmelCase  ,  **_UpperCAmelCase							):
   raise Exception(F"You cannot use ``setdefault`` on a {self.__class__.__name__} instance."							)




 def     a       (			self  ,  *_UpperCAmelCase  ,  **_UpperCAmelCase							):
   raise Exception(F"You cannot use ``pop`` on a {self.__class__.__name__} instance."							)




 def     a       (			self  ,  *_UpperCAmelCase  ,  **_UpperCAmelCase							):
   raise Exception(F"You cannot use ``update`` on a {self.__class__.__name__} instance."							)




 def __getitem__(			self  ,  _UpperCAmelCase							):
   if isinstance(_UpperCAmelCase  ,  _UpperCAmelCase							):
     __UpperCAmelCase	:  List[Any]		=     dict(self.items()							)
     return inner_dict[k]
   else:
     return self.to_tuple()[k]




 def __setattr__(			self  ,  _UpperCAmelCase  ,  _UpperCAmelCase							):
   if name in self.keys() and value is not None:
     # Don't call self.__setitem__ to avoid recursion errors
     super().__setitem__(_UpperCAmelCase  ,  _UpperCAmelCase							)
   super().__setattr__(_UpperCAmelCase  ,  _UpperCAmelCase							)




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




 def     a       (			self							):
   return tuple(self[k] for k in self.keys()							)








from __future__ import annotations





def  _snake_case		(snake_case_					:     int  )							->		int | None:
  for r in range(1    ,       snake_case_  ):
    __UpperCAmelCase	:  List[str]		=     []
    for x in range(n - 1  ):
      __UpperCAmelCase	:  Union[str, Any]		=     pow(snake_case_    ,       snake_case_    ,       snake_case_  )
      if val in li:
        break
      li.append(snake_case_  )
    else:
      return r
  return None


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

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





