from math import factorial

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



def lowerCamelCase  (   SCREAMING_SNAKE_CASE	):
    '''simple docstring'''







    if not isinstance(SCREAMING_SNAKE_CASE  ,			SCREAMING_SNAKE_CASE	):
        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(SCREAMING_SNAKE_CASE	)	)



def lowerCamelCase  (   SCREAMING_SNAKE_CASE = 60  ,			SCREAMING_SNAKE_CASE = 1_000_000	):
    '''simple docstring'''







    if not isinstance(SCREAMING_SNAKE_CASE  ,			SCREAMING_SNAKE_CASE	) or not isinstance(SCREAMING_SNAKE_CASE  ,			SCREAMING_SNAKE_CASE	):
        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
    __UpperCamelCase     :Dict			  =		0
    # the cached sizes of the previous chains
    __UpperCamelCase     :dict[int, int]			  =		{}

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

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

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

        __UpperCamelCase     :Tuple			  =		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()}')






import argparse
import json

from tqdm import tqdm



def lowerCamelCase  (   ):
    '''simple docstring'''







    __UpperCamelCase     :Tuple			  =		argparse.ArgumentParser()

    # Required parameters
    parser.add_argument(
        '''--src_path'''  ,			type=SCREAMING_SNAKE_CASE  ,			default='''biencoder-nq-dev.json'''  ,			help='''Path to raw DPR training data'''  ,			)
    parser.add_argument(
        '''--evaluation_set'''  ,			type=SCREAMING_SNAKE_CASE  ,			help='''where to store parsed evaluation_set file'''  ,			)
    parser.add_argument(
        '''--gold_data_path'''  ,			type=SCREAMING_SNAKE_CASE  ,			help='''where to store parsed gold_data_path file'''  ,			)
    __UpperCamelCase     :str			  =		parser.parse_args()

    with open(args.src_path  ,			'''r'''	) as src_file, open(args.evaluation_set  ,			'''w'''	) as eval_file, open(
        args.gold_data_path  ,			'''w'''	) as gold_file:
        __UpperCamelCase     :List[str]			  =		json.load(SCREAMING_SNAKE_CASE	)
        for dpr_record in tqdm(SCREAMING_SNAKE_CASE	):
            __UpperCamelCase     :List[str]			  =		dpr_record['''question''']
            __UpperCamelCase     :Tuple			  =		[context['''title'''] for context in dpr_record['''positive_ctxs''']]
            eval_file.write(question + '''\n'''	)
            gold_file.write('''\t'''.join(SCREAMING_SNAKE_CASE	) + '''\n'''	)


if __name__ == "__main__":
    main()





