


'''simple docstring'''







from __future__ import annotations


def      SCREAMING_SNAKE_CASE_ (  _UpperCAmelCase     :     list[list[int]]   ,_UpperCAmelCase     :     list[list[int]]  )  ->      list[int]:
       assert len(_UpperCAmelCase  ) == len(_UpperCAmelCase  )

       _a   :			Any					 =len(_UpperCAmelCase  )
       _a   :			List[str]					 =list(range(_UpperCAmelCase  )  )
       _a   :			List[str]					 =[-1] * n  # who the donor has donated to
       _a   :			int					 =[-1] * n  # who the recipient has received from
       _a   :			int					 =[0] * n

       while unmatched_donors:
              _a   :			Union[str, Any]					 =unmatched_donors[0]
              _a   :			Any					 =donor_pref[donor]
              _a   :			int					 =donor_preference[num_donations[donor]]
              num_donations[donor] += 1
              _a   :			Any					 =recipient_pref[recipient]
              _a   :			str					 =rec_record[recipient]

              if prev_donor != -1:
                     if rec_preference.index(_UpperCAmelCase  ) > rec_preference.index(_UpperCAmelCase  ):
                            _a   :			Any					 =donor
                            _a   :			int					 =recipient
                            unmatched_donors.append(_UpperCAmelCase  )
                            unmatched_donors.remove(_UpperCAmelCase  )
              else:
                     _a   :			Any					 =donor
                     _a   :			List[Any]					 =recipient
                     unmatched_donors.remove(_UpperCAmelCase  )
       return donor_record






'''simple docstring'''







import math


def      SCREAMING_SNAKE_CASE_ (  _UpperCAmelCase     :     int  )  ->      int:
       return sum(int(_UpperCAmelCase  ) for digit in str(_UpperCAmelCase  )  )


def      SCREAMING_SNAKE_CASE_ (  _UpperCAmelCase     :     int = 30  )  ->      int:
       _a   :			List[Any]					 =[]
       for digit in range(2   ,100  ):
              for power in range(2   ,100  ):
                     _a   :			Optional[Any]					 =int(math.pow(_UpperCAmelCase   ,_UpperCAmelCase  )  )
                     if digit == digit_sum(_UpperCAmelCase  ):
                            digit_to_powers.append(_UpperCAmelCase  )

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


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


