





UpperCAmelCase	:	Tuple		     =       {0: [2, 3], 1: [0], 2: [1], 3: [4], 4: []}

UpperCAmelCase	:	Optional[int]		     =       {0: [1, 2, 3], 1: [2], 2: [0], 3: [4], 4: [5], 5: [3]}
def      _A       (		SCREAMING_SNAKE_CASE     :   dict[int, list[int]]       ,       SCREAMING_SNAKE_CASE     :   int       ,       SCREAMING_SNAKE_CASE     :   list[bool]						):





  """simple docstring"""



  a__	:					Union[str, Any]										=True
  a__	:					Any										=[]

  for neighbour in graph[vert]:
    if not visited[neighbour]:
      order += topology_sort(SCREAMING_SNAKE_CASE       ,       SCREAMING_SNAKE_CASE       ,       SCREAMING_SNAKE_CASE						)

  order.append(SCREAMING_SNAKE_CASE						)

  return order
def      _A       (		SCREAMING_SNAKE_CASE     :   dict[int, list[int]]       ,       SCREAMING_SNAKE_CASE     :   int       ,       SCREAMING_SNAKE_CASE     :   list[bool]						):





  """simple docstring"""



  a__	:					List[str]										=True
  a__	:					Tuple										=[vert]

  for neighbour in reversed_graph[vert]:
    if not visited[neighbour]:
      component += find_components(SCREAMING_SNAKE_CASE       ,       SCREAMING_SNAKE_CASE       ,       SCREAMING_SNAKE_CASE						)

  return component





def      _A       (		SCREAMING_SNAKE_CASE     :   dict[int, list[int]]						):





  """simple docstring"""



  a__	:					str										=len(SCREAMING_SNAKE_CASE						) * [False]
  a__	:					dict[int, list[int]]										={vert: [] for vert in range(len(SCREAMING_SNAKE_CASE						)						)}

  for vert, neighbours in graph.items():
    for neighbour in neighbours:
      reversed_graph[neighbour].append(SCREAMING_SNAKE_CASE						)

  a__	:					Optional[Any]										=[]
  for i, was_visited in enumerate(SCREAMING_SNAKE_CASE						):
    if not was_visited:
      order += topology_sort(SCREAMING_SNAKE_CASE       ,       SCREAMING_SNAKE_CASE       ,       SCREAMING_SNAKE_CASE						)

  a__	:					List[str]										=[]
  a__	:					Optional[Any]										=len(SCREAMING_SNAKE_CASE						) * [False]

  for i in range(len(SCREAMING_SNAKE_CASE						)						):
    a__	:					Any										=order[len(SCREAMING_SNAKE_CASE						) - i - 1]
    if not visited[vert]:
      a__	:					List[str]										=find_components(SCREAMING_SNAKE_CASE       ,       SCREAMING_SNAKE_CASE       ,       SCREAMING_SNAKE_CASE						)
      components_list.append(SCREAMING_SNAKE_CASE						)

  return components_list







'''simple docstring'''





import math





def 	lowerCAmelCase_				(					)    ->      None:


     '''simple docstring'''




     UpperCAmelCase_           =   input("Enter message: "			)
     UpperCAmelCase_           =   int(input(f"""Enter key [2-{len(snake_case_			) - 1}]: """			)			)
     UpperCAmelCase_           =   input("Encryption/Decryption [e/d]: "			)

     if mode.lower().startswith("e"			):
          UpperCAmelCase_           =   encrypt_message(snake_case_					,    snake_case_			)
     elif mode.lower().startswith("d"			):
          UpperCAmelCase_           =   decrypt_message(snake_case_					,    snake_case_			)

     # Append pipe symbol (vertical bar) to identify spaces at the end.
     print(f"""Output:\n{text + "|"}"""			)





def 	lowerCAmelCase_				(					snake_case_       : int					,    snake_case_       : str			)    ->      str:


     '''simple docstring'''




     UpperCAmelCase_           =   [""] * key
     for col in range(snake_case_			):
          UpperCAmelCase_           =   col
          while pointer < len(snake_case_			):
               cipher_text[col] += message[pointer]
               pointer += key
     return "".join(snake_case_			)





def 	lowerCAmelCase_				(					snake_case_       : int					,    snake_case_       : str			)    ->      str:


     '''simple docstring'''




     UpperCAmelCase_           =   math.ceil(len(snake_case_			) / key			)
     UpperCAmelCase_           =   key
     UpperCAmelCase_           =   (num_cols * num_rows) - len(snake_case_			)
     UpperCAmelCase_           =   [""] * num_cols
     UpperCAmelCase_           =   0
     UpperCAmelCase_           =   0

     for symbol in message:
          plain_text[col] += symbol
          col += 1

          if (
              (col == num_cols)
              or (col == num_cols - 1)
              and (row >= num_rows - num_shaded_boxes)
          ):
               UpperCAmelCase_           =   0
               row += 1

     return "".join(snake_case_			)


if __name__ == "__main__":
    import doctest

    doctest.testmod()
    main()




