






a						:			List[Any]     	=					{
    "a": "AAAAA",
    "b": "AAAAB",
    "c": "AAABA",
    "d": "AAABB",
    "e": "AABAA",
    "f": "AABAB",
    "g": "AABBA",
    "h": "AABBB",
    "i": "ABAAA",
    "j": "BBBAA",
    "k": "ABAAB",
    "l": "ABABA",
    "m": "ABABB",
    "n": "ABBAA",
    "o": "ABBAB",
    "p": "ABBBA",
    "q": "ABBBB",
    "r": "BAAAA",
    "s": "BAAAB",
    "t": "BAABA",
    "u": "BAABB",
    "v": "BBBAB",
    "w": "BABAA",
    "x": "BABAB",
    "y": "BABBA",
    "z": "BABBB",
    " ": " ",
}


a						:			Optional[Any]     	=					{value: key for key, value in encode_dict.items()}






def 							lowerCamelCase__ (       __lowerCamelCase     :	str						):
  __UpperCAmelCase				:      Tuple	 =    """"""
  for letter in word.lower():
    if letter.isalpha() or letter == " ":
      encoded += encode_dict[letter]
    else:
      raise Exception("""encode() accepts only letters of the alphabet and spaces"""						)
  return encoded






def 							lowerCamelCase__ (       __lowerCamelCase     :	str						):
  if set(__lowerCamelCase						) - {"A", "B", " "} != set():
    raise Exception("""decode() accepts only 'A', 'B' and spaces"""						)
  __UpperCAmelCase				:      int	 =    """"""
  for word in coded.split():
    while len(__lowerCamelCase						) != 0:
      decoded += decode_dict[word[:5]]
      __UpperCAmelCase				:      Any	 =    word[5:]
    decoded += " "
  return decoded.strip()


if __name__ == "__main__":
       from doctest import testmod

       testmod()







'''simple docstring'''

# Author: OMKAR PATHAK, Nwachukwu Chidiebere

# Use a Python dictionary to construct the graph.
from __future__ import annotations

from pprint import pformat
from typing import Generic, TypeVar

__lowerCAmelCase		     =  TypeVar('''T''')

class       __magic_name__		(       Generic[T]  ):







							def __init__(				self   :			int      ,_UpperCAmelCase   :			bool = True						):
									_a	: dict[T, list[T]]								=				{}  # dictionary of lists
									_a	: Tuple								=				directed







							def 				__lowercase     (				self   :			Union[str, Any]      ,_UpperCAmelCase   :			T      ,_UpperCAmelCase   :			T						):

									if not self.directed:  # For undirected graphs
											# if both source vertex and destination vertex are both present in the
											# adjacency list, add destination vertex to source vertex list of adjacent
											# vertices and add source vertex to destination vertex list of adjacent
											# vertices.
											if source_vertex in self.adj_list and destination_vertex in self.adj_list:
													self.adj_list[source_vertex].append(_UpperCAmelCase						)
													self.adj_list[destination_vertex].append(_UpperCAmelCase						)
											# if only source vertex is present in adjacency list, add destination vertex
											# to source vertex list of adjacent vertices, then create a new vertex with
											# destination vertex as key and assign a list containing the source vertex
											# as it's first adjacent vertex.
											elif source_vertex in self.adj_list:
													self.adj_list[source_vertex].append(_UpperCAmelCase						)
													_a	: Optional[Any]								=				[source_vertex]
											# if only destination vertex is present in adjacency list, add source vertex
											# to destination vertex list of adjacent vertices, then create a new vertex
											# with source vertex as key and assign a list containing the source vertex
											# as it's first adjacent vertex.
											elif destination_vertex in self.adj_list:
													self.adj_list[destination_vertex].append(_UpperCAmelCase						)
													_a	: Union[str, Any]								=				[destination_vertex]
											# if both source vertex and destination vertex are not present in adjacency
											# list, create a new vertex with source vertex as key and assign a list
											# containing the destination vertex as it's first adjacent vertex also
											# create a new vertex with destination vertex as key and assign a list
											# containing the source vertex as it's first adjacent vertex.
											else:
													_a	: Union[str, Any]								=				[destination_vertex]
													_a	: Optional[int]								=				[source_vertex]
									else:  # For directed graphs
											# if both source vertex and destination vertex are present in adjacency
											# list, add destination vertex to source vertex list of adjacent vertices.
											if source_vertex in self.adj_list and destination_vertex in self.adj_list:
													self.adj_list[source_vertex].append(_UpperCAmelCase						)
											# if only source vertex is present in adjacency list, add destination
											# vertex to source vertex list of adjacent vertices and create a new vertex
											# with destination vertex as key, which has no adjacent vertex
											elif source_vertex in self.adj_list:
													self.adj_list[source_vertex].append(_UpperCAmelCase						)
													_a	: int								=				[]
											# if only destination vertex is present in adjacency list, create a new
											# vertex with source vertex as key and assign a list containing destination
											# vertex as first adjacent vertex
											elif destination_vertex in self.adj_list:
													_a	: Tuple								=				[destination_vertex]
											# if both source vertex and destination vertex are not present in adjacency
											# list, create a new vertex with source vertex as key and a list containing
											# destination vertex as it's first adjacent vertex. Then create a new vertex
											# with destination vertex as key, which has no adjacent vertex
											else:
													_a	: Tuple								=				[destination_vertex]
													_a	: str								=				[]

									return self







							def __repr__(				self   :			int						):
									return pformat(self.adj_list						)




