


'''simple docstring'''


import operator




def      lowerCamelCase					(      lowerCamelCase  :      List[Any]							,						lowerCamelCase  :      Tuple = False							,						lowerCamelCase  :      List[str] = None):
   A_						:  str          =				operator.lt if reverse else operator.gt
   A_						:  Optional[Any]          =				solution or []

   if not arr:
      return solution

   A_						:  Dict          =				[arr.pop(0)]
   for i, item in enumerate(snake_case_):
      if _operator(snake_case_							,						sublist[-1]):
         sublist.append(snake_case_)
         arr.pop(snake_case_)

    #  merging sublist into solution list
   if not solution:
      solution.extend(snake_case_)
   else:
      while sublist:
         A_						:  Union[str, Any]          =				sublist.pop(0)
         for i, xx in enumerate(snake_case_):
            if not _operator(snake_case_							,						snake_case_):
               solution.insert(snake_case_							,						snake_case_)
               break
         else:
            solution.append(snake_case_)

   strand_sort(snake_case_							,						snake_case_							,						snake_case_)
   return solution


if __name__ == "__main__":
     assert strand_sort([4, 3, 5, 1, 2]) == [1, 2, 3, 4, 5]
     assert strand_sort([4, 3, 5, 1, 2], reverse=True) == [5, 4, 3, 2, 1]




'''simple docstring'''


from __future__ import annotations




def      lowerCamelCase					(      lowerCamelCase  :      dict							,						lowerCamelCase  :      str):
      A_   ,					A_						:  List[Any]          =				set(lowerCamelCase), [start]

      while stack:
            A_						:  Optional[Any]          =				stack.pop()
            explored.add(lowerCamelCase)
            # Differences from BFS:
            # 1) pop last element instead of first one
            # 2) add adjacent elements to stack without exploring them
            for adj in reversed(graph[v]):
                  if adj not in explored:
                        stack.append(lowerCamelCase)
      return explored


__magic_name__			=      {
    'A': ['B', 'C', 'D'],
    'B': ['A', 'D', 'E'],
    'C': ['A', 'F'],
    'D': ['B', 'D'],
    'E': ['B', 'F'],
    'F': ['C', 'E', 'G'],
    'G': ['F'],
}

if __name__ == "__main__":
     import doctest

     doctest.testmod()
     print(depth_first_search(G, 'A'))
