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







def   UpperCamelCase_(					__magic_name__      :	Optional[Any]	,    __magic_name__      :	int	,    __magic_name__      :	Dict	,    __magic_name__      :	int      ):


							"""simple docstring"""





							_lowerCAmelCase :Optional[Any]      	=						sum(a_i[j] for j in range(__lowerCamelCase	,    len(__lowerCamelCase      )      )      )
							_lowerCAmelCase :Dict      	=						sum(a_i[j] * base[j] for j in range(min(len(__lowerCamelCase      )	,    __lowerCamelCase      )      )      )

							_lowerCAmelCase	,  _lowerCAmelCase :List[Any]      	=						0, 0
							_lowerCAmelCase :Optional[int]      	=						n - i

							_lowerCAmelCase :Union[str, Any]      	=						memo.get(__lowerCamelCase      )

							if sub_memo is not None:
														_lowerCAmelCase :List[Any]      	=						sub_memo.get(__lowerCamelCase      )

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

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

														else:
																					_lowerCAmelCase :Union[str, Any]      	=						[]
							else:
														_lowerCAmelCase :List[Any]      	=						{c: []}
														_lowerCAmelCase :Any      	=						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 :str      	=						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
														_lowerCAmelCase	,  _lowerCAmelCase :str      	=						compute(__lowerCamelCase	,    __lowerCamelCase	,    i + dn	,    __lowerCamelCase      )
														diff += _diff
														dn += terms_jumped

							_lowerCAmelCase :Optional[Any]      	=						sub_memo[c]

							# keep jumps sorted by # of terms skipped
							_lowerCAmelCase :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   UpperCamelCase_(					__magic_name__      :	List[str]	,    __magic_name__      :	Dict	,    __magic_name__      :	Optional[int]	,    __magic_name__      :	Optional[Any]      ):


							"""simple docstring"""





							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)
							_lowerCAmelCase :int      	=						i
							_lowerCAmelCase	,  _lowerCAmelCase	,  _lowerCAmelCase :Tuple      	=						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
														_lowerCAmelCase :Union[str, Any]      	=						ds_c + ds_b
														diff += addend
														_lowerCAmelCase :Any      	=						0
														for j in range(__lowerCamelCase      ):
																					_lowerCAmelCase :Dict      	=						a_i[j] + addend
																					_lowerCAmelCase	,  _lowerCAmelCase :Any      	=						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   UpperCamelCase_(					__magic_name__      :	List[Any]	,    __magic_name__      :	Tuple	,    __magic_name__      :	List[Any]      ):


							"""simple docstring"""





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

														if addend == 0:
																					break

							while addend > 0:
														_lowerCAmelCase	,  _lowerCAmelCase :int      	=						divmod(__lowerCamelCase	,    10      )
														digits.append(__lowerCamelCase      )







def   UpperCamelCase_(					__magic_name__      :	int = 10**15      ):


							"""simple docstring"""





							_lowerCAmelCase :List[Any]      	=						[1]
							_lowerCAmelCase :Any      	=						1
							_lowerCAmelCase :List[str]      	=						0
							while True:
														_lowerCAmelCase	,  _lowerCAmelCase :Optional[Any]      	=						next_term(__lowerCamelCase	,    20	,    i + dn	,    __lowerCamelCase      )
														dn += terms_jumped
														if dn == n - i:
																					break

							_lowerCAmelCase :int      	=						0
							for j in range(len(__lowerCamelCase      )      ):
														a_n += digits[j] * 10**j
							return a_n


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




from __future__ import annotations






class     __a			:



	def __init__(    self				:     Optional[int]					,						snake_case_				:     int = 0)->				List[str]:
						__lowerCAmelCase						 =key



	def 		UpperCamelCase				(    self				:     Any					,						snake_case_				:     str					,						snake_case_				:     int)->				list[str]:
						assert isinstance(snake_case_					,						snake_case_) and isinstance(snake_case_					,						snake_case_)

						__lowerCAmelCase						 =key or self.__key or 1

						# make sure key is an appropriate size
						key %= 2_55

						return [chr(ord(snake_case_) ^ key) for ch in content]



	def 		UpperCamelCase				(    self				:     Tuple					,						snake_case_				:     str					,						snake_case_				:     int)->				list[str]:
						assert isinstance(snake_case_					,						snake_case_) and isinstance(snake_case_					,						snake_case_)

						__lowerCAmelCase						 =key or self.__key or 1

						# make sure key is an appropriate size
						key %= 2_55

						return [chr(ord(snake_case_) ^ key) for ch in content]



	def 		UpperCamelCase				(    self				:     str					,						snake_case_				:     str					,						snake_case_				:     int = 0)->				str:
						assert isinstance(snake_case_					,						snake_case_) and isinstance(snake_case_					,						snake_case_)

						__lowerCAmelCase						 =key or self.__key or 1

						# make sure key can be any size
						while key > 2_55:
											key -= 2_55

						# This will be returned
						__lowerCAmelCase						 =""""""

						for ch in content:
											ans += chr(ord(snake_case_) ^ key)

						return ans



	def 		UpperCamelCase				(    self				:     Tuple					,						snake_case_				:     str					,						snake_case_				:     int = 0)->				str:
						assert isinstance(snake_case_					,						snake_case_) and isinstance(snake_case_					,						snake_case_)

						__lowerCAmelCase						 =key or self.__key or 1

						# make sure key can be any size
						while key > 2_55:
											key -= 2_55

						# This will be returned
						__lowerCAmelCase						 =""""""

						for ch in content:
											ans += chr(ord(snake_case_) ^ key)

						return ans



	def 		UpperCamelCase				(    self				:     int					,						snake_case_				:     str					,						snake_case_				:     int = 0)->				bool:
						assert isinstance(snake_case_					,						snake_case_) and isinstance(snake_case_					,						snake_case_)

						try:
											with open(snake_case_) as fin, open("""encrypt.out"""					,						"""w+""") as fout:
																# actual encrypt-process
																for line in fin:
																					fout.write(self.encrypt_string(snake_case_					,						snake_case_))

						except OSError:
											return False

						return True



	def 		UpperCamelCase				(    self				:     Tuple					,						snake_case_				:     str					,						snake_case_				:     int)->				bool:
						assert isinstance(snake_case_					,						snake_case_) and isinstance(snake_case_					,						snake_case_)

						try:
											with open(snake_case_) as fin, open("""decrypt.out"""					,						"""w+""") as fout:
																# actual encrypt-process
																for line in fin:
																					fout.write(self.decrypt_string(snake_case_					,						snake_case_))

						except OSError:
											return False

						return True


# Tests
# crypt = XORCipher()
# key = 67

# # test encrypt
# print(crypt.encrypt("hallo welt",key))
# # test decrypt
# print(crypt.decrypt(crypt.encrypt("hallo welt",key), key))

# # test encrypt_string
# print(crypt.encrypt_string("hallo welt",key))

# # test decrypt_string
# print(crypt.decrypt_string(crypt.encrypt_string("hallo welt",key),key))

# if (crypt.encrypt_file("test.txt",key)):
#       print("encrypt successful")
# else:
#       print("encrypt unsuccessful")

# if (crypt.decrypt_file("encrypt.out",key)):
#       print("decrypt successful")
# else:
#       print("decrypt unsuccessful")




