


"""simple docstring"""
from typing import Any



class      _UpperCAmelCase					:






		'''simple docstring'''

		def __init__(self   ):





			'''simple docstring'''

			__snake_case      :		List[Any]         =							[]
			__snake_case      :		Union[str, Any]         =							0



		def __str__(self   ):





			'''simple docstring'''

			__snake_case      :		Optional[Any]         =							'''<''' + str(self.stack   )[1:-1] + '''>'''
			return printed



		def 							SCREAMING_SNAKE_CASE    (self							,			a_   ):





			'''simple docstring'''

			self.stack.append(a_   )
			__snake_case      :		str         =							self.length + 1



		def 							SCREAMING_SNAKE_CASE    (self   ):





			'''simple docstring'''

			self.rotate(1   )
			__snake_case      :		List[str]         =							self.stack[self.length - 1]
			__snake_case      :		Union[str, Any]         =							self.stack[:-1]
			self.rotate(self.length - 1   )
			__snake_case      :		int         =							self.length - 1
			return dequeued



		def 							SCREAMING_SNAKE_CASE    (self							,			a_   ):





			'''simple docstring'''

			for _ in range(a_   ):
				__snake_case      :		Optional[int]         =							self.stack[0]
				__snake_case      :		Dict         =							self.stack[1:]
				self.put(a_   )
				__snake_case      :		str         =							self.length - 1



		def 							SCREAMING_SNAKE_CASE    (self   ):





			'''simple docstring'''

			__snake_case      :		Union[str, Any]         =							self.get()
			self.put(a_   )
			self.rotate(self.length - 1   )
			return front



		def 							SCREAMING_SNAKE_CASE    (self   ):





			'''simple docstring'''

			return self.length






"""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)



