





class        _a:







		def __init__(    self ,						__snake_case ,						__snake_case ,						__snake_case				)      ->      Optional[int]:


							'''simple docstring'''

							_snake_case       :					Any				       =   name
							_snake_case       :					str				       =   value
							_snake_case       :					Any				       =   weight







		def __repr__(    self				)      ->      List[str]:


							'''simple docstring'''

							return f"""{self.__class__.__name__}({self.name}, {self.value}, {self.weight})"""







		def        lowercase       (    self				)      ->      str:


							'''simple docstring'''

							return self.value







		def        lowercase       (    self				)      ->      List[Any]:


							'''simple docstring'''

							return self.name







		def        lowercase       (    self				)      ->      Optional[int]:


							'''simple docstring'''

							return self.weight







		def        lowercase       (    self				)      ->      int:


							'''simple docstring'''

							return self.value / self.weight







def    A				(							UpperCAmelCase  ,  UpperCAmelCase  ,  UpperCAmelCase				):
					_snake_case       :					Dict				       =   []
					for i in range(len(UpperCAmelCase				)				):
										menu.append(Things(name[i]  ,  value[i]  ,  weight[i]				)				)
					return menu







def    A				(							UpperCAmelCase  ,  UpperCAmelCase  ,  UpperCAmelCase				):
					_snake_case       :					List[str]				       =   sorted(UpperCAmelCase  ,  key=UpperCAmelCase  ,  reverse=UpperCAmelCase				)
					_snake_case       :					str				       =   []
					_snake_case       :					str				       =   0.0, 0.0
					for i in range(len(UpperCAmelCase				)				):
										if (total_cost + items_copy[i].get_weight()) <= max_cost:
															result.append(items_copy[i]				)
															total_cost += items_copy[i].get_weight()
															total_value += items_copy[i].get_value()
					return (result, total_value)







def    A				(							):
					pass


if __name__ == "__main__":
			import doctest

			doctest.testmod()






from math import factorial

__lowerCAmelCase :dict[str, int]     =    {str(digit): factorial(digit) for digit in range(10)}







def    A				(							UpperCAmelCase				):
					if not isinstance(UpperCAmelCase  ,  UpperCAmelCase				):
										raise TypeError("Parameter number must be int"				)

					if number < 0:
										raise ValueError("Parameter number must be greater than or equal to 0"				)

					# Converts number in string to iterate on its digits and adds its factorial.
					return sum(DIGIT_FACTORIAL[digit] for digit in str(UpperCAmelCase				)				)







def    A				(							UpperCAmelCase = 60  ,  UpperCAmelCase = 1_000_000				):

					if not isinstance(UpperCAmelCase  ,  UpperCAmelCase				) or not isinstance(UpperCAmelCase  ,  UpperCAmelCase				):
										raise TypeError("Parameters chain_length and number_limit must be int"				)

					if chain_length <= 0 or number_limit <= 0:
										raise ValueError(
										    "Parameters chain_length and number_limit must be greater than 0"				)

					# the counter for the chains with the exact desired length
					_snake_case       :					Optional[int]				       =   0
					# the cached sizes of the previous chains
					_snake_case       :					dict[int, int]				       =   {}

					for start_chain_element in range(1  ,  UpperCAmelCase				):
										# The temporary set will contain the elements of the chain
										_snake_case       :					Union[str, Any]				       =   set()
										_snake_case       :					Tuple				       =   0

										# Stop computing the chain when you find a cached size, a repeating item or the
										# length is greater then the desired one.
										_snake_case       :					str				       =   start_chain_element
										while (
										    chain_element not in chain_sets_lengths
										    and chain_element not in chain_set
										    and chain_set_length <= chain_length
										):
															chain_set.add(UpperCAmelCase				)
															chain_set_length += 1
															_snake_case       :					Optional[Any]				       =   digit_factorial_sum(UpperCAmelCase				)

										if chain_element in chain_sets_lengths:
															chain_set_length += chain_sets_lengths[chain_element]

										_snake_case       :					List[Any]				       =   chain_set_length

										# If chain contains the exact amount of elements increase the counter
										if chain_set_length == chain_length:
															chains_counter += 1

					return chains_counter


if __name__ == "__main__":
							import doctest

							doctest.testmod()
							print(F'''{solution()}''')