from __future__ import annotations







def 						UpperCAmelCase							(		lowerCAmelCase_							)						->						list[int]:
     assert (
         isinstance(lowerCAmelCase_    ,   lowerCAmelCase_							) and mask > 0
     ), f"""mask needs to be positive integer, your input {mask}"""
     a	:     str						      =    []
     a	:     int						      =    mask

     while submask:
          all_submasks.append(lowerCAmelCase_							)
          a	:     Union[str, Any]						      =    (submask - 1) & mask

     return all_submasks


if __name__ == "__main__":
  import doctest

  doctest.testmod()
import math







def 						UpperCAmelCase							(		lowerCAmelCase_							)						->						int:
     return sum(int(lowerCAmelCase_							) for digit in str(lowerCAmelCase_							)							)







def 						UpperCAmelCase							(		lowerCAmelCase_ = 3_0							)						->						int:
     a	:     Optional[int]						      =    []
     for digit in range(2    ,   1_0_0							):
          for power in range(2    ,   1_0_0							):
               a	:     List[str]						      =    int(math.pow(lowerCAmelCase_    ,   lowerCAmelCase_							)							)
               if digit == digit_sum(lowerCAmelCase_							):
                    digit_to_powers.append(lowerCAmelCase_							)

     digit_to_powers.sort()
     return digit_to_powers[n - 1]


if __name__ == "__main__":
  print(solution())