


snake_case__				:	List[Any]					       =					range(2, 20 + 1)
snake_case__				:	Optional[int]					       =					[10**k for k in range(ks[-1] + 1)]
snake_case__				:	dict[int, dict[int, list[list[int]]]]					       =					{}


def    __lowerCamelCase   (      A__						: Optional[Any]						,						A__						: str						,						A__						: Any						,						A__						: Dict					)     ->    Dict:
   lowerCamelCase_						:   Optional[Any]		= sum(a_i[j] for j in range(A__						,						len(A__					)					)					)
   lowerCamelCase_						:   List[str]		= sum(a_i[j] * base[j] for j in range(min(len(A__					)						,						A__					)					)					)

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

   lowerCamelCase_						:   Dict		= memo.get(A__					)

   if sub_memo is not None:
      lowerCamelCase_						:   Union[str, Any]		= sub_memo.get(A__					)

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

         if max_jump >= 0:
            lowerCamelCase_,	lowerCamelCase_,	lowerCamelCase_						:   List[str]		= jumps[max_jump]
            # since the difference between jumps is cached, add c
            lowerCamelCase_						:   Tuple		= diff + c
            for j in range(min(A__						,						len(A__					)					)					):
               lowerCamelCase_,	lowerCamelCase_						:   int		= divmod(A__						,						10					)
            if new_c > 0:
               add(A__						,						A__						,						A__					)

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

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

   if k > ks[0]:
      while True:
         # keep doing smaller jumps
         lowerCamelCase_,	lowerCamelCase_						:   int		= next_term(A__						,						k - 1						,						i + dn						,						A__					)
         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
      lowerCamelCase_,	lowerCamelCase_						:   Union[str, Any]		= compute(A__						,						A__						,						i + dn						,						A__					)
      diff += _diff
      dn += terms_jumped

   lowerCamelCase_						:   List[Any]		= sub_memo[c]

   # keep jumps sorted by # of terms skipped
   lowerCamelCase_						:   int		= 0
   while j < len(A__					):
      if jumps[j][1] > dn:
         break
      j += 1

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


def    __lowerCamelCase   (      A__						: int						,						A__						: str						,						A__						: List[str]						,						A__						: Tuple					)     ->    Optional[int]:
   if i >= n:
      return 0, i
   if k > len(A__					):
      a_i.extend([0 for _ in range(k - len(A__					)					)]					)

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

   while i < n:
      i += 1
      lowerCamelCase_						:   Any		= ds_c + ds_b
      diff += addend
      lowerCamelCase_						:   Tuple		= 0
      for j in range(A__					):
         lowerCamelCase_						:   str		= a_i[j] + addend
         lowerCamelCase_,	lowerCamelCase_						:   str		= divmod(A__						,						10					)

         ds_c += a_i[j]

      if addend > 0:
         break

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


def    __lowerCamelCase   (      A__						: int						,						A__						: Dict						,						A__						: Tuple					)     ->    Any:
   for j in range(A__						,						len(A__					)					):
      lowerCamelCase_						:   List[str]		= digits[j] + addend
      if s >= 10:
         lowerCamelCase_,	lowerCamelCase_						:   List[Any]		= divmod(A__						,						10					)
         lowerCamelCase_						:   Optional[Any]		= addend // 10 + quotient
      else:
         lowerCamelCase_						:   Any		= s
         lowerCamelCase_						:   Tuple		= addend // 10

      if addend == 0:
         break

   while addend > 0:
      lowerCamelCase_,	lowerCamelCase_						:   str		= divmod(A__						,						10					)
      digits.append(A__					)


def    __lowerCamelCase   (      A__						: int = 10**15					)     ->    int:
   lowerCamelCase_						:   int		= [1]
   lowerCamelCase_						:   int		= 1
   lowerCamelCase_						:   int		= 0
   while True:
      lowerCamelCase_,	lowerCamelCase_						:   Optional[Any]		= next_term(A__						,						20						,						i + dn						,						A__					)
      dn += terms_jumped
      if dn == n - i:
         break

   lowerCamelCase_						:   Union[str, Any]		= 0
   for j in range(len(A__					)					):
      a_n += digits[j] * 10**j
   return a_n


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









class   SCREAMING_SNAKE_CASE_			:




       '''simple docstring'''



       def __init__(						self				:				Tuple		,				__a				:				int							)					->Optional[int]:
          lowerCamelCase_						:   Optional[Any]		= n
          lowerCamelCase_						:   Dict		= [None] * self.n
          lowerCamelCase_						:   int		= 0  # index of the first element
          lowerCamelCase_						:   str		= 0
          lowerCamelCase_						:   Optional[Any]		= 0



       def __len__(						self				:				List[str]							)					->int:
          return self.size



       def 				_lowerCAmelCase							(						self				:				str							)					->bool:
          return self.size == 0



       def 				_lowerCAmelCase							(						self				:				str							)					->Any:
          return False if self.is_empty() else self.array[self.front]



       def 				_lowerCAmelCase							(						self				:				Union[str, Any]		,				__a				:				int							)					->List[Any]:
          if self.size >= self.n:
             raise Exception("""QUEUE IS FULL"""							)

          lowerCamelCase_						:   Tuple		= data
          lowerCamelCase_						:   Tuple		= (self.rear + 1) % self.n
          self.size += 1
          return self




       def 				_lowerCAmelCase							(						self				:				Tuple							)					->int:
          if self.size == 0:
             raise Exception("""UNDERFLOW"""							)

          lowerCamelCase_						:   str		= self.array[self.front]
          lowerCamelCase_						:   str		= None
          lowerCamelCase_						:   Optional[Any]		= (self.front + 1) % self.n
          self.size -= 1
          return temp





