


"""simple docstring"""


__snake_case    					=					range(2, 20 + 1)
__snake_case    					=					[10**k for k in range(ks[-1] + 1)]
__snake_case    					=					{}


def    _lowerCamelCase   (     lowerCamelCase__	:							Tuple       ,		lowerCamelCase__	:							Dict       ,		lowerCamelCase__	:							List[Any]       ,		lowerCamelCase__	:							Dict  ):
 lowercase__       :       Optional[int]				=						sum(a_i[j] for j in range(lowerCamelCase__       ,		len(lowerCamelCase__  )  )  )
 lowercase__       :       Tuple				=						sum(a_i[j] * base[j] for j in range(min(len(lowerCamelCase__  )       ,		lowerCamelCase__  )  )  )

 lowercase__	,       lowercase__       :       Dict				=						0, 0
 lowercase__       :       Tuple				=						n - i

 lowercase__       :       List[Any]				=						memo.get(lowerCamelCase__  )

 if sub_memo is not None:
  lowercase__       :       List[str]				=						sub_memo.get(lowerCamelCase__  )

  if jumps is not None and len(lowerCamelCase__  ) > 0:
   # find and make the largest jump without going over
   lowercase__       :       Optional[Any]				=						-1
   for _k in range(len(lowerCamelCase__  ) - 1       ,		-1       ,		-1  ):
    if jumps[_k][2] <= k and jumps[_k][1] <= max_dn:
     lowercase__       :       List[Any]				=						_k
     break

   if max_jump >= 0:
    lowercase__	,       lowercase__	,       lowercase__       :       str				=						jumps[max_jump]
    # since the difference between jumps is cached, add c
    lowercase__       :       Union[str, Any]				=						diff + c
    for j in range(min(lowerCamelCase__       ,		len(lowerCamelCase__  )  )  ):
     lowercase__	,       lowercase__       :       Optional[Any]				=						divmod(lowerCamelCase__       ,		10  )
    if new_c > 0:
     add(lowerCamelCase__       ,		lowerCamelCase__       ,		lowerCamelCase__  )

  else:
   lowercase__       :       Optional[Any]				=						[]
 else:
  lowercase__       :       List[str]				=						{c: []}
  lowercase__       :       int				=						sub_memo

 if dn >= max_dn or c + diff >= base[k]:
  return diff, dn

 if k > ks[0]:
  while True:
   # keep doing smaller jumps
   lowercase__	,       lowercase__       :       int				=						next_term(lowerCamelCase__       ,		k - 1       ,		i + dn       ,		lowerCamelCase__  )
   diff += _diff
   dn += terms_jumped

   if dn >= max_dn or c + diff >= base[k]:
    break
 else:
  # would be too small a jump, just compute sequential terms instead
  lowercase__	,       lowercase__       :       int				=						compute(lowerCamelCase__       ,		lowerCamelCase__       ,		i + dn       ,		lowerCamelCase__  )
  diff += _diff
  dn += terms_jumped

 lowercase__       :       Tuple				=						sub_memo[c]

 # keep jumps sorted by # of terms skipped
 lowercase__       :       Optional[Any]				=						0
 while j < len(lowerCamelCase__  ):
  if jumps[j][1] > dn:
   break
  j += 1

 # cache the jump for this value digitsum(b) and c
 sub_memo[c].insert(lowerCamelCase__       ,		(diff, dn, k)  )
 return (diff, dn)


def    _lowerCamelCase   (     lowerCamelCase__	:							List[Any]       ,		lowerCamelCase__	:							int       ,		lowerCamelCase__	:							Any       ,		lowerCamelCase__	:							Dict  ):
 if i >= n:
  return 0, i
 if k > len(lowerCamelCase__  ):
  a_i.extend([0 for _ in range(k - len(lowerCamelCase__  )  )]  )

 # note: a_i -> b * 10^k + c
 # ds_b -> digitsum(b)
 # ds_c -> digitsum(c)
 lowercase__       :       Optional[Any]				=						i
 lowercase__	,       lowercase__	,       lowercase__       :       Any				=						0, 0, 0
 for j in range(len(lowerCamelCase__  )  ):
  if j >= k:
   ds_b += a_i[j]
  else:
   ds_c += a_i[j]

 while i < n:
  i += 1
  lowercase__       :       Optional[Any]				=						ds_c + ds_b
  diff += addend
  lowercase__       :       List[Any]				=						0
  for j in range(lowerCamelCase__  ):
   lowercase__       :       Dict				=						a_i[j] + addend
   lowercase__	,       lowercase__       :       int				=						divmod(lowerCamelCase__       ,		10  )

   ds_c += a_i[j]

  if addend > 0:
   break

 if addend > 0:
  add(lowerCamelCase__       ,		lowerCamelCase__       ,		lowerCamelCase__  )
 return diff, i - start_i


def    _lowerCamelCase   (     lowerCamelCase__	:							Any       ,		lowerCamelCase__	:							Dict       ,		lowerCamelCase__	:							Union[str, Any]  ):
 for j in range(lowerCamelCase__       ,		len(lowerCamelCase__  )  ):
  lowercase__       :       List[Any]				=						digits[j] + addend
  if s >= 10:
   lowercase__	,       lowercase__       :       Any				=						divmod(lowerCamelCase__       ,		10  )
   lowercase__       :       Tuple				=						addend // 10 + quotient
  else:
   lowercase__       :       Any				=						s
   lowercase__       :       Optional[Any]				=						addend // 10

  if addend == 0:
   break

 while addend > 0:
  lowercase__	,       lowercase__       :       Tuple				=						divmod(lowerCamelCase__       ,		10  )
  digits.append(lowerCamelCase__  )


def    _lowerCamelCase   (     lowerCamelCase__	:							int = 10**15  ):
 lowercase__       :       int				=						[1]
 lowercase__       :       List[str]				=						1
 lowercase__       :       Any				=						0
 while True:
  lowercase__	,       lowercase__       :       int				=						next_term(lowerCamelCase__       ,		20       ,		i + dn       ,		lowerCamelCase__  )
  dn += terms_jumped
  if dn == n - i:
   break

 lowercase__       :       Dict				=						0
 for j in range(len(lowerCamelCase__  )  ):
  a_n += digits[j] * 10**j
 return a_n


if __name__ == "__main__":
   print(F"{solution() = }")



"""simple docstring"""


from ..utils import DummyObject, requires_backends

class 				_SCREAMING_SNAKE_CASE				(							metaclass=__UpperCAmelCase  ):
   """simple docstring"""



   _a   :       Optional[int]									=    ['''note_seq''']


   def __init__(						self ,     *lowerCamelCase__ ,     **lowerCamelCase__						)      ->							Tuple:
    requires_backends(self ,     ["""note_seq"""]						)


   @classmethod
   def 					UpperCAmelCase__(						cls ,     *lowerCamelCase__ ,     **lowerCamelCase__						)      ->							Tuple:
    requires_backends(cls ,     ["""note_seq"""]						)







   @classmethod
   def 					UpperCAmelCase__(						cls ,     *lowerCamelCase__ ,     **lowerCamelCase__						)      ->							Tuple:
    requires_backends(cls ,     ["""note_seq"""]						)