'''simple docstring'''




class      lowerCamelCase_     :
      '''simple docstring'''

      class      lowerCamelCase_     :
            '''simple docstring'''

            __UpperCamelCase:  List[str]      =						"""_prev""", """_data""", """_next"""




            def __init__(	self						:    int						, A						:    Tuple						, A						:    Tuple						, A						:    Optional[int]	):
                   _UpperCAmelCase					:  List[str]											=   link_p
                   _UpperCAmelCase					:  Tuple											=   element
                   _UpperCAmelCase					:  Dict											=   link_n





            def 					_A     (	self						:    Optional[int]	):
                   return (
                       F""" Prev -> {self._prev is not None}, Next -> {self._next is not None}"""
                   )




      def __init__(	self						:    List[str]	):
             _UpperCAmelCase					:  Tuple											=   self._Node(snake_case_						, snake_case_						, snake_case_	)
             _UpperCAmelCase					:  List[Any]											=   self._Node(snake_case_						, snake_case_						, snake_case_	)
             _UpperCAmelCase					:  Any											=   self._trailer
             _UpperCAmelCase					:  List[Any]											=   self._header
             _UpperCAmelCase					:  Dict											=   0




      def __len__(	self						:    Optional[int]	):
             return self._size




      def 					_A     (	self						:    Tuple	):
             return self.__len__() == 0




      def 					_A     (	self						:    Tuple						, A						:    Optional[Any]						, A						:    int						, A						:    Union[str, Any]	):
             # Create new_node by setting it's prev.link -> header
             # setting it's next.link -> trailer
             _UpperCAmelCase					:  List[str]											=   self._Node(snake_case_						, snake_case_						, snake_case_	)
             _UpperCAmelCase					:  Tuple											=   new_node
             _UpperCAmelCase					:  Dict											=   new_node
             self._size += 1
             return self





      def 					_A     (	self						:    Any						, A						:    int	):
             _UpperCAmelCase					:  Tuple											=   node._prev
             _UpperCAmelCase					:  int											=   node._next

             _UpperCAmelCase					:  Union[str, Any]											=   successor
             _UpperCAmelCase					:  Dict											=   predecessor
             self._size -= 1
             _UpperCAmelCase					:  Optional[Any]											=   node._data
             _UpperCAmelCase					:  List[str]											=   None
             del node
             return temp

class      lowerCamelCase_     (_DoublyLinkedBase   ):
      '''simple docstring'''

      def 					_A     (	self						:    int	):
             if self.is_empty():
                    raise Exception("List is empty"	)
             return self._header._next._data




      def 					_A     (	self						:    int	):
             if self.is_empty():
                    raise Exception("List is empty"	)
             return self._trailer._prev._data




      def 					_A     (	self						:    Optional[int]						, A						:    List[str]	):
             return self._insert(self._header						, snake_case_						, self._header._next	)




      def 					_A     (	self						:    Optional[Any]						, A						:    Any	):
             return self._insert(self._trailer._prev						, snake_case_						, self._trailer	)




      def 					_A     (	self						:    int	):
             if self.is_empty():
                    raise IndexError("remove_first from empty list"	)
             return self._delete(self._header._next	)





      def 					_A     (	self						:    Optional[Any]	):
             if self.is_empty():
                    raise IndexError("remove_first from empty list"	)
             return self._delete(self._trailer._prev	)


'''simple docstring'''




from __future__ import annotations

from collections.abc import Generator

def      UpperCamelCase_							( _UpperCAmelCase  :				int   )   ->   Generator[int, None, None]:


       """simple docstring"""







       if not isinstance(_UpperCAmelCase      ,     _UpperCAmelCase   ) or n < 1:
              raise Exception("Sequence only defined for positive integers"   )

       yield n
       while n != 1:
              if n % 2 == 0:
                     n //= 2
              else:
                     _UpperCAmelCase					:  Optional[Any]											=   3 * n + 1
              yield n

def      UpperCamelCase_							( )   ->   Any:


       """simple docstring"""







       _UpperCAmelCase					:  str											=   43
       _UpperCAmelCase					:  Optional[int]											=   tuple(collatz_sequence(_UpperCAmelCase   )   )
       print(_UpperCAmelCase   )
       print(F"""Collatz sequence from {n} took {len(_UpperCAmelCase   )} steps."""   )


if __name__ == "__main__":
  main()

