


import heapq as hq
import math
from collections.abc import Iterator




class        lowerCamelCase      :


	def __init__(						self							,    lowercase__):
							__UpperCAmelCase :       List[str]  						=  str(id_)
							__UpperCAmelCase :       str  						=  None
							__UpperCAmelCase :       Any  						=  None
							__UpperCAmelCase :       str  						=  []
							__UpperCAmelCase :       Union[str, Any]  						=  {}  # {vertex:distance}


	def __lt__(						self							,    lowercase__):
							return self.key < other.key


	def __repr__(						self):
							return self.id


	def    A(						self							,    lowercase__):
							self.neighbors.append(lowercase__)


	def    A(						self							,    lowercase__							,    lowercase__):
							__UpperCAmelCase :       int  						=  weight






def 						__SCREAMING_SNAKE_CASE       (					lowercase_			,					lowercase_			,					lowercase_			,					lowercase_			)		->    List[str]:




						'''simple docstring'''







						graph[a - 1].add_neighbor(graph[b - 1]			)
						graph[b - 1].add_neighbor(graph[a - 1]			)
						# add the edges:
						graph[a - 1].add_edge(graph[b - 1]			,					lowercase_			)
						graph[b - 1].add_edge(graph[a - 1]			,					lowercase_			)




def 						__SCREAMING_SNAKE_CASE       (					lowercase_			,					lowercase_			)		->    list:




						'''simple docstring'''







						__UpperCAmelCase :       int  						=  []
						for u in graph:
												__UpperCAmelCase :       List[str]  						=  math.inf
												__UpperCAmelCase :       Optional[Any]  						=  None
						__UpperCAmelCase :       List[Any]  						=  0
						__UpperCAmelCase :       Tuple  						=  graph[:]
						while q:
												__UpperCAmelCase :       Any  						=  min(lowercase_			)
												q.remove(lowercase_			)
												for v in u.neighbors:
																		if (v in q) and (u.edges[v.id] < v.key):
																								__UpperCAmelCase :       List[Any]  						=  u
																								__UpperCAmelCase :       List[str]  						=  u.edges[v.id]
						for i in range(1			,					len(lowercase_			)			):
												a.append((int(graph[i].id			) + 1, int(graph[i].pi.id			) + 1)			)
						return a




def 						__SCREAMING_SNAKE_CASE       (					lowercase_			,					lowercase_			)		->    Iterator[tuple]:




						'''simple docstring'''







						for u in graph:
												__UpperCAmelCase :       Any  						=  math.inf
												__UpperCAmelCase :       Optional[Any]  						=  None
						__UpperCAmelCase :       Dict  						=  0

						__UpperCAmelCase :       Any  						=  list(lowercase_			)
						hq.heapify(lowercase_			)

						while h:
												__UpperCAmelCase :       Union[str, Any]  						=  hq.heappop(lowercase_			)
												for v in u.neighbors:
																		if (v in h) and (u.edges[v.id] < v.key):
																								__UpperCAmelCase :       Any  						=  u
																								__UpperCAmelCase :       Dict  						=  u.edges[v.id]
																								hq.heapify(lowercase_			)

						for i in range(1			,					len(lowercase_			)			):
												yield (int(graph[i].id			) + 1, int(graph[i].pi.id			) + 1)




def 						__SCREAMING_SNAKE_CASE       (					)		->    None:




						'''simple docstring'''









if __name__ == "__main__":
				import doctest

				doctest.testmod()





from string import ascii_uppercase

lowerCAmelCase							=						{char: i for i, char in enumerate(ascii_uppercase)}
lowerCAmelCase							=						dict(enumerate(ascii_uppercase))




def 						__SCREAMING_SNAKE_CASE       (					lowercase_			,					lowercase_			)		->    str:




						'''simple docstring'''







						__UpperCAmelCase :       List[Any]  						=  len(lowercase_			)
						__UpperCAmelCase :       int  						=  0
						while True:
												if x == i:
																		__UpperCAmelCase :       List[str]  						=  0
												if len(lowercase_			) == len(lowercase_			):
																		break
												key += key[i]
												i += 1
						return key




def 						__SCREAMING_SNAKE_CASE       (					lowercase_			,					lowercase_			)		->    str:




						'''simple docstring'''







						__UpperCAmelCase :       str  						=  ''''''
						__UpperCAmelCase :       List[str]  						=  0
						for letter in message:
												if letter == " ":
																		cipher_text += " "
												else:
																		__UpperCAmelCase :       Optional[int]  						=  (dicta[letter] - dicta[key_new[i]]) % 26
																		i += 1
																		cipher_text += dicta[x]
						return cipher_text




def 						__SCREAMING_SNAKE_CASE       (					lowercase_			,					lowercase_			)		->    str:




						'''simple docstring'''







						__UpperCAmelCase :       Optional[int]  						=  ''''''
						__UpperCAmelCase :       List[str]  						=  0
						for letter in cipher_text:
												if letter == " ":
																		or_txt += " "
												else:
																		__UpperCAmelCase :       int  						=  (dicta[letter] + dicta[key_new[i]] + 26) % 26
																		i += 1
																		or_txt += dicta[x]
						return or_txt




def 						__SCREAMING_SNAKE_CASE       (					)		->    None:




						'''simple docstring'''







						__UpperCAmelCase :       Optional[int]  						=  '''THE GERMAN ATTACK'''
						__UpperCAmelCase :       List[Any]  						=  '''SECRET'''
						__UpperCAmelCase :       Optional[int]  						=  generate_key(lowercase_			,					lowercase_			)
						__UpperCAmelCase :       List[str]  						=  cipher_text(lowercase_			,					lowercase_			)
						print(f"Encrypted Text = {s}"			)
						print(f"Original Text = {original_text(lowercase_			,					lowercase_			)}"			)


if __name__ == "__main__":
				import doctest

				doctest.testmod()
				main()

