






from __future__ import annotations

from collections.abc import Iterable, Iterator
from typing import Any, Generic, TypeVar

a 			=							TypeVar('T', bound=bool)
class 							__snake_case(       Generic[T]   ):



 def __init__(						self : Tuple			,		UpperCAmelCase__ : T						):

    """simple docstring"""






    lowercase__    :						T       =			value
    lowercase__    :						SkewNode[T] | None       =			None
    lowercase__    :						SkewNode[T] | None       =			None



 @property
 def     UpperCAmelCase     (						self : Tuple						):

    """simple docstring"""






    return self._value







 @staticmethod
 def     UpperCAmelCase     (						UpperCAmelCase__ : SkewNode[T] | None			,		UpperCAmelCase__ : SkewNode[T] | None						):

    """simple docstring"""






    if not roota:
       return roota

    if not roota:
       return roota

    if roota.value > roota.value:
       lowercase__  ,       lowercase__    :						Optional[int]       =			roota, roota

    lowercase__    :						Any       =			roota
    lowercase__    :						Tuple       =			roota.right
    lowercase__    :						List[Any]       =			roota.left
    lowercase__    :						Union[str, Any]       =			SkewNode.merge(UpperCAmelCase__			,		UpperCAmelCase__						)

    return result
class 							__snake_case(       Generic[T]   ):



 def __init__(						self : Tuple			,		UpperCAmelCase__ : Iterable[T] | None = ()						):

    """simple docstring"""






    lowercase__    :						SkewNode[T] | None       =			None
    if data:
       for item in data:
          self.insert(UpperCAmelCase__						)



 def __bool__(						self : Dict						):

    """simple docstring"""






    return self._root is not None



 def __iter__(						self : List[Any]						):

    """simple docstring"""






    lowercase__    :						list[Any]       =			[]
    while self:
       result.append(self.pop()						)

    # Pushing items back to the heap not to clear it.
    for item in result:
       self.insert(UpperCAmelCase__						)

    return iter(UpperCAmelCase__						)



 def     UpperCAmelCase     (						self : Optional[Any]			,		UpperCAmelCase__ : T						):

    """simple docstring"""






    lowercase__    :						List[str]       =			SkewNode.merge(self._root			,		SkewNode(UpperCAmelCase__						)						)



 def     UpperCAmelCase     (						self : int						):

    """simple docstring"""






    lowercase__    :						str       =			self.top()
    lowercase__    :						Dict       =			(
        SkewNode.merge(self._root.left			,		self._root.right						) if self._root else None
    )

    return result



 def     UpperCAmelCase     (						self : str						):

    """simple docstring"""






    if not self._root:
       raise IndexError("""Can't get top element for the empty heap."""						)
    return self._root.value







 def     UpperCAmelCase     (						self : Tuple						):

    """simple docstring"""






    lowercase__    :						List[str]       =			None


if __name__ == "__main__":
 import doctest

 doctest.testmod()










def    a__    (	A       ):
   return " ".join([word[::-1] for word in input_str.split()]       )


if __name__ == "__main__":
 import doctest

 doctest.testmod()


