'''simple docstring'''




from __future__ import annotations

from typing import TypedDict






class 		__A       (__magic_name__   ):
       snake_case       :str
       snake_case       :int





def _lowercase	(      lowerCamelCase__						)					->       list[str]:





       """simple docstring"""


       if not isinstance(lowerCamelCase__							,    lowerCamelCase__						):
              raise TypeError("The parameter s type must be str."						)

       return [s[i:] + s[:i] for i in range(len(lowerCamelCase__						)						)]

def _lowercase	(      lowerCamelCase__						)					->       BWTTransformDict:





       """simple docstring"""


       if not isinstance(lowerCamelCase__							,    lowerCamelCase__						):
              raise TypeError("The parameter s type must be str."						)
       if not s:
              raise ValueError("The parameter s must not be empty."						)

       __UpperCAmelCase  :				Union[str, Any]       				=		all_rotations(lowerCamelCase__						)
       rotations.sort()  # sort the list of rotations in alphabetically order
       # make a string composed of the last char of each rotation
       __UpperCAmelCase  :				BWTTransformDict       				=		{
           "bwt_string": "".join([word[-1] for word in rotations]						),
           "idx_original_string": rotations.index(lowerCamelCase__						),
       }
       return response

def _lowercase	(      lowerCamelCase__							,    lowerCamelCase__						)					->       str:





       """simple docstring"""


       if not isinstance(lowerCamelCase__							,    lowerCamelCase__						):
              raise TypeError("The parameter bwt_string type must be str."						)
       if not bwt_string:
              raise ValueError("The parameter bwt_string must not be empty."						)
       try:
              __UpperCAmelCase  :				Tuple       				=		int(lowerCamelCase__						)
       except ValueError:
              raise TypeError(
                  "The parameter idx_original_string type must be int or passive"
                  " of cast to int."						)
       if idx_original_string < 0:
              raise ValueError("The parameter idx_original_string must not be lower than 0."						)
       if idx_original_string >= len(lowerCamelCase__						):
              raise ValueError(
                  "The parameter idx_original_string must be lower than" " len(bwt_string)."						)

       __UpperCAmelCase  :				List[str]       				=		[""] * len(lowerCamelCase__						)
       for _ in range(len(lowerCamelCase__						)						):
              for i in range(len(lowerCamelCase__						)						):
                     __UpperCAmelCase  :				Optional[Any]       				=		bwt_string[i] + ordered_rotations[i]
              ordered_rotations.sort()
       return ordered_rotations[idx_original_string]


if __name__ == "__main__":
   _a   :	List[Any] 							=   "Provide a string that I will generate its BWT transform: "
   _a   :	Union[str, Any] 							=   input(entry_msg).strip()
   _a   :	Union[str, Any] 							=   bwt_transform(s)
   print(
       f"""Burrows Wheeler transform for string '{s}' results """
       f"""in '{result['bwt_string']}'"""
   )
   _a   :	Optional[Any] 							=   reverse_bwt(result["bwt_string"], result["idx_original_string"])
   print(
       f"""Reversing Burrows Wheeler transform for entry '{result['bwt_string']}' """
       f"""we get original string '{original_string}'"""
   )







'''simple docstring'''




def _lowercase	(      lowerCamelCase__							,    lowerCamelCase__						)					->       int:





       """simple docstring"""


       return number | (1 << position)

def _lowercase	(      lowerCamelCase__							,    lowerCamelCase__						)					->       int:





       """simple docstring"""


       return number & ~(1 << position)

def _lowercase	(      lowerCamelCase__							,    lowerCamelCase__						)					->       int:





       """simple docstring"""


       return number ^ (1 << position)

def _lowercase	(      lowerCamelCase__							,    lowerCamelCase__						)					->       bool:





       """simple docstring"""


       return ((number >> position) & 1) == 1

def _lowercase	(      lowerCamelCase__							,    lowerCamelCase__						)					->       int:





       """simple docstring"""


       return int((number & (1 << position)) != 0						)


if __name__ == "__main__":
   import doctest

   doctest.testmod()






