

'''simple docstring'''

from math import factorial

A_       						=							{str(digit): factorial(digit) for digit in range(10)}





def    A_  ( snake_case ):
		if not isinstance(__lowerCAmelCase      ,       __lowerCAmelCase ):
				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(__lowerCAmelCase ) )





def    A_  ( snake_case = 60      ,       snake_case = 1000000 ):

		if not isinstance(__lowerCAmelCase      ,       __lowerCAmelCase ) or not isinstance(__lowerCAmelCase      ,       __lowerCAmelCase ):
				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
		SCREAMING_SNAKE_CASE:List[str]						      =					0
		# the cached sizes of the previous chains
		SCREAMING_SNAKE_CASE:Optional[Any]						      =					{}

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

				# Stop computing the chain when you find a cached size, a repeating item or the
				# length is greater then the desired one.
				SCREAMING_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(__lowerCAmelCase )
						chain_set_length += 1
						SCREAMING_SNAKE_CASE:List[Any]						      =					digit_factorial_sum(__lowerCAmelCase )

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

				SCREAMING_SNAKE_CASE:Optional[int]						      =					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()}''')









'''simple docstring'''

import random





def    A_  ( snake_case      ,       snake_case      ,       snake_case = False ):
  SCREAMING_SNAKE_CASE:dict						      =					{i: [] for i in range(snake_case )}

  # if probability is greater or equal than 1, then generate a complete graph
  if probability >= 1:
    return complete_graph(snake_case )
  # if probability is lower or equal than 0, then return a graph without edges
  if probability <= 0:
    return graph

  # for each couple of nodes, add an edge from u to v
  # if the number randomly generated is greater than probability probability
  for i in range(snake_case ):
    for j in range(i + 1      ,       snake_case ):
      if random.random() < probability:
        graph[i].append(snake_case )
        if not directed:
          # if the graph is undirected, add an edge in from j to i, either
          graph[j].append(snake_case )
  return graph





def    A_  ( snake_case ):
  return {
      i: [j for j in range(snake_case ) if i != j] for i in range(snake_case )
  }


if __name__ == "__main__":
    import doctest

    doctest.testmod()






