






from __future__ import annotations

from typing import TypedDict







class  _lowercase   (   _A						):
      _a							:						str
      _a							:						int







def 			A__							(      _a  :					str	):





 '''simple docstring'''







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

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







def 			A__							(      _a  :					str	):





 '''simple docstring'''







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

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







def 			A__							(      _a  :					str		,  _a  :					int	):





 '''simple docstring'''







 if not isinstance(_a		,  _a	):
  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:
  snake_case__  :    str							       =int(_a	)
 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(_a	):
  raise ValueError(
      """The parameter idx_original_string must be lower than""" """ len(bwt_string)."""	)

 snake_case__  :    Tuple							       =[""""""] * len(_a	)
 for _ in range(len(_a	)	):
  for i in range(len(_a	)	):
   snake_case__  :    str							       =bwt_string[i] + ordered_rotations[i]
  ordered_rotations.sort()
 return ordered_rotations[idx_original_string]


if __name__ == "__main__":
       __lowerCamelCase	:		int										=   """Provide a string that I will generate its BWT transform: """
       __lowerCamelCase	:		Dict										=   input(entry_msg).strip()
       __lowerCamelCase	:		Optional[int]										=   bwt_transform(s)
       print(
           F"Burrows Wheeler transform for string '{s}' results "
           F"in '{result['bwt_string']}'"
       )
       __lowerCamelCase	:		str										=   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}'"
       )













from string import ascii_uppercase

__lowerCamelCase	:		List[Any]										=   {str(ord(c) - 55): c for c in ascii_uppercase}







def 			A__							(      _a  :					int		,  _a  :					int	):





 '''simple docstring'''







 if isinstance(_a		,  _a	):
  raise TypeError("""int() can't convert non-string with explicit base"""	)
 if num < 0:
  raise ValueError("""parameter must be positive int"""	)
 if isinstance(_a		,  _a	):
  raise TypeError("""'str' object cannot be interpreted as an integer"""	)
 if isinstance(_a		,  _a	):
  raise TypeError("""'float' object cannot be interpreted as an integer"""	)
 if base in (0, 1):
  raise ValueError("""base must be >= 2"""	)
 if base > 36:
  raise ValueError("""base must be <= 36"""	)
 snake_case__  :    Union[str, Any]							       =""""""
 snake_case__  :    List[str]							       =0
 snake_case__  :    List[Any]							       =0
 while div != 1:
  snake_case__       ,   snake_case__  :    Union[str, Any]							       =divmod(_a		,  _a	)
  if base >= 11 and 9 < mod < 36:
   snake_case__  :    Dict							       =ALPHABET_VALUES[str(_a	)]
  else:
   snake_case__  :    Optional[Any]							       =str(_a	)
  new_value += actual_value
  snake_case__  :    Dict							       =num // base
  snake_case__  :    Tuple							       =div
  if div == 0:
   return str(new_value[::-1]	)
  elif div == 1:
   new_value += str(_a	)
   return str(new_value[::-1]	)

 return new_value[::-1]


if __name__ == "__main__":
       import doctest

       doctest.testmod()

       for base in range(2, 37):
              for num in range(10_00):
                     assert int(decimal_to_any(num, base), base) == num, (
                         num,
                         base,
                         decimal_to_any(num, base),
                         int(decimal_to_any(num, base), base),
                     )





