




def lowerCamelCase__  (     _lowercase ):

     '''simple docstring'''


     UpperCAmelCase_     :				Union[str, Any]  =     ''''''
     for ch in key:
          if ch == " " or ch not in key_no_dups and ch.isalpha():
               key_no_dups += ch
     return key_no_dups







def lowerCamelCase__  (     _lowercase ):

     '''simple docstring'''


     UpperCAmelCase_     :				Union[str, Any]  =     [chr(i + 65 ) for i in range(26 )]
     # Remove duplicate characters from key
     UpperCAmelCase_     :				Optional[Any]  =     remove_duplicates(key.upper() )
     UpperCAmelCase_     :				Tuple  =     len(_lowercase )
     # First fill cipher with key characters
     UpperCAmelCase_     :				List[str]  =     {alphabet[i]: char for i, char in enumerate(_lowercase )}
     # Then map remaining characters in alphabet to
     # the alphabet from the beginning
     for i in range(len(_lowercase )					,		26 ):
          UpperCAmelCase_     :				List[Any]  =     alphabet[i - offset]
          # Ensure we are not mapping letters to letters previously mapped
          while char in key:
               offset -= 1
               UpperCAmelCase_     :				Any  =     alphabet[i - offset]
          UpperCAmelCase_     :				Dict  =     char
     return cipher_alphabet







def lowerCamelCase__  (     _lowercase					,		_lowercase ):

     '''simple docstring'''


     return "".join(cipher_map.get(_lowercase					,		_lowercase ) for ch in message.upper() )







def lowerCamelCase__  (     _lowercase					,		_lowercase ):

     '''simple docstring'''


     UpperCAmelCase_     :				Tuple  =     {v: k for k, v in cipher_map.items()}
     return "".join(rev_cipher_map.get(_lowercase					,		_lowercase ) for ch in message.upper() )







def lowerCamelCase__  (     ):

     '''simple docstring'''


     UpperCAmelCase_     :				List[str]  =     input('''Enter message to encode or decode: ''' ).strip()
     UpperCAmelCase_     :				Tuple  =     input('''Enter keyword: ''' ).strip()
     UpperCAmelCase_     :				Optional[Any]  =     input('''Encipher or decipher? E/D:''' ).strip()[0].lower()
     try:
          UpperCAmelCase_     :				List[str]  =     {'''e''': encipher, '''d''': decipher}[option]
     except KeyError:
          raise KeyError('''invalid input option''' )
     UpperCAmelCase_     :				Any  =     create_cipher_map(_lowercase )
     print(func(_lowercase					,		_lowercase ) )


if __name__ == "__main__":
     import doctest

     doctest.testmod()
     main()







"""simple docstring"""


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




class 						__UpperCamelCase     :
					def __init__(							self							:	Union[str, Any]     , UpperCAmelCase							:	List[Any]   )	->       List[str]:
											lowerCAmelCase   :Dict						=			str(id_   )
											lowerCAmelCase   :str						=			None
											lowerCAmelCase   :Any						=			None
											lowerCAmelCase   :List[str]						=			[]
											lowerCAmelCase   :List[Any]						=			{}  # {vertex:distance}
					def __lt__(							self							:	Union[str, Any]     , UpperCAmelCase							:	Any   )	->       str:
											return self.key < other.key
					def __repr__(							self							:	Union[str, Any]   )	->       Dict:
											return self.id
					def        UpperCAmelCase__ (							self							:	Any     , UpperCAmelCase							:	Tuple   )	->       List[str]:
											self.neighbors.append(UpperCAmelCase   )
					def        UpperCAmelCase__ (							self							:	str     , UpperCAmelCase							:	Optional[Any]     , UpperCAmelCase							:	List[Any]   )	->       Optional[int]:
											lowerCAmelCase   :str						=			weight


def        UpperCAmelCase      (					a__     ,      a__     ,      a__     ,      a__ ):





						'''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]     ,      a__ )
						graph[b - 1].add_edge(graph[a - 1]     ,      a__ )


def        UpperCAmelCase      (					a__     ,      a__ ):





						'''simple docstring'''






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


def        UpperCAmelCase      (					a__     ,      a__ ):





						'''simple docstring'''






						for u in graph:
												lowerCAmelCase   :List[str]						=			math.inf
												lowerCAmelCase   :str						=			None
						lowerCAmelCase   :Optional[int]						=			0

						lowerCAmelCase   :Dict						=			list(a__ )
						hq.heapify(a__ )

						while h:
												lowerCAmelCase   :Union[str, Any]						=			hq.heappop(a__ )
												for v in u.neighbors:
																		if (v in h) and (u.edges[v.id] < v.key):
																								lowerCAmelCase   :int						=			u
																								lowerCAmelCase   :List[Any]						=			u.edges[v.id]
																								hq.heapify(a__ )

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


def        UpperCAmelCase      (					):





						'''simple docstring'''








if __name__ == "__main__":
		import doctest

		doctest.testmod()