

from typing import Any


class      lowerCamelCase_ :




 def __init__(			self							):
   __UpperCAmelCase	:  int		=     []
   __UpperCAmelCase	:  List[str]		=     0




 def __str__(			self							):
   __UpperCAmelCase	:  Union[str, Any]		=     '<' + str(self.stack							)[1:-1] + '>'
   return printed




 def     a       (			self  ,  _UpperCAmelCase							):
   self.stack.append(_UpperCAmelCase							)
   __UpperCAmelCase	:  int		=     self.length + 1




 def     a       (			self							):
   self.rotate(1							)
   __UpperCAmelCase	:  Optional[int]		=     self.stack[self.length - 1]
   __UpperCAmelCase	:  Optional[int]		=     self.stack[:-1]
   self.rotate(self.length - 1							)
   __UpperCAmelCase	:  Any		=     self.length - 1
   return dequeued




 def     a       (			self  ,  _UpperCAmelCase							):
   for _ in range(_UpperCAmelCase							):
     __UpperCAmelCase	:  Dict		=     self.stack[0]
     __UpperCAmelCase	:  Optional[int]		=     self.stack[1:]
     self.put(_UpperCAmelCase							)
     __UpperCAmelCase	:  List[Any]		=     self.length - 1




 def     a       (			self							):
   __UpperCAmelCase	:  List[str]		=     self.get()
   self.put(_UpperCAmelCase							)
   self.rotate(self.length - 1							)
   return front




 def     a       (			self							):
   return self.length








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)





