






'''simple docstring'''





def __UpperCAmelCase   (					A					:			str			,       A					:			Union[str, Any]		)    ->   Dict:
			UpperCAmelCase_      :       Optional[Any]          =       ''''''
			for i in table:
						res += inp[i - 1]
			return res
def __UpperCAmelCase   (					A					:			Any		)    ->   int:
			return data[1:] + data[0]
def __UpperCAmelCase   (					A					:			str			,       A					:			Optional[Any]		)    ->   List[str]:
			UpperCAmelCase_      :       Any          =       ''''''
			for i in range(len(A		)		):
						if a[i] == b[i]:
									res += "0"
						else:
									res += "1"
			return res
def __UpperCAmelCase   (					A					:			List[str]			,       A					:			Tuple		)    ->   Optional[Any]:
			UpperCAmelCase_      :       Tuple          =       int('''0b''' + data[0] + data[-1]			,       2		)
			UpperCAmelCase_      :       int          =       int('''0b''' + data[1:3]			,       2		)
			return bin(s[row][col]		)[2:]
def __UpperCAmelCase   (					A					:			List[str]			,       A					:			Union[str, Any]			,       A					:			Union[str, Any]			,       A					:			Union[str, Any]			,       A					:			int		)    ->   Union[str, Any]:
			UpperCAmelCase_      :       Union[str, Any]          =       message[:4]
			UpperCAmelCase_      :       Tuple          =       message[4:]
			UpperCAmelCase_      :       Tuple          =       apply_table(A			,       A		)
			UpperCAmelCase_      :       Optional[int]          =       xor(A			,       A		)
			UpperCAmelCase_      :       List[Any]          =       apply_sbox(A			,       temp[:4]		)  # noqa: E741
			UpperCAmelCase_      :       int          =       apply_sbox(A			,       temp[4:]		)
			UpperCAmelCase_      :       Dict          =       '''0''' * (2 - len(A		)) + l  # noqa: E741
			UpperCAmelCase_      :       Tuple          =       '''0''' * (2 - len(A		)) + r
			UpperCAmelCase_      :       Union[str, Any]          =       apply_table(l + r			,       A		)
			UpperCAmelCase_      :       Optional[Any]          =       xor(A			,       A		)
			return temp + right


if __name__ == "__main__":
						_UpperCamelCase						:						Dict  =					input('Enter 10 bit key: ')
						_UpperCamelCase						:						List[str]  =					input('Enter 8 bit message: ')

						_UpperCamelCase						:						Dict  =					[6, 3, 7, 4, 8, 5, 10, 9]
						_UpperCamelCase						:						str  =					[3, 5, 2, 7, 4, 10, 1, 9, 8, 6]
						_UpperCamelCase						:						Any  =					[2, 4, 3, 1]
						_UpperCamelCase						:						Union[str, Any]  =					[2, 6, 3, 1, 4, 8, 5, 7]
						_UpperCamelCase						:						List[str]  =					[4, 1, 3, 5, 7, 2, 8, 6]
						_UpperCamelCase						:						Optional[int]  =					[4, 1, 2, 3, 2, 3, 4, 1]
						_UpperCamelCase						:						List[Any]  =					[[1, 0, 3, 2], [3, 2, 1, 0], [0, 2, 1, 3], [3, 1, 3, 2]]
						_UpperCamelCase						:						Optional[Any]  =					[[0, 1, 2, 3], [2, 0, 1, 3], [3, 0, 1, 0], [2, 1, 0, 3]]

						# key generation
						_UpperCamelCase						:						int  =					apply_table(key, paa_table)
						_UpperCamelCase						:						str  =					temp[:5]
						_UpperCamelCase						:						Tuple  =					temp[5:]
						_UpperCamelCase						:						List[str]  =					left_shift(left)
						_UpperCamelCase						:						Optional[Any]  =					left_shift(right)
						_UpperCamelCase						:						Dict  =					apply_table(left + right, pa_table)
						_UpperCamelCase						:						Tuple  =					left_shift(left)
						_UpperCamelCase						:						Union[str, Any]  =					left_shift(right)
						_UpperCamelCase						:						Any  =					left_shift(left)
						_UpperCamelCase						:						int  =					left_shift(right)
						_UpperCamelCase						:						Dict  =					apply_table(left + right, pa_table)

						# encryption
						_UpperCamelCase						:						Tuple  =					apply_table(message, IP)
						_UpperCamelCase						:						List[Any]  =					function(expansion, sa, sa, keya, temp)
						_UpperCamelCase						:						List[Any]  =					temp[4:] + temp[:4]
						_UpperCamelCase						:						Any  =					function(expansion, sa, sa, keya, temp)
						_UpperCamelCase						:						Any  =					apply_table(temp, IP_inv)
						print('Cipher text is:', CT)

						# decryption
						_UpperCamelCase						:						Optional[Any]  =					apply_table(CT, IP)
						_UpperCamelCase						:						Any  =					function(expansion, sa, sa, keya, temp)
						_UpperCamelCase						:						List[str]  =					temp[4:] + temp[:4]
						_UpperCamelCase						:						Optional[Any]  =					function(expansion, sa, sa, keya, temp)
						_UpperCamelCase						:						Tuple  =					apply_table(temp, IP_inv)
						print('Plain text after decypting is:', PT)










'''simple docstring'''





_UpperCamelCase						:						List[str]  =					[sum(int(c, 10) ** 2 for c in i.__str__()) for i in range(100_000)]
def __UpperCAmelCase   (					A					:			int		)    ->   int:
			UpperCAmelCase_      :       str          =       0
			while number:
						# Increased Speed Slightly by checking every 5 digits together.
						sum_of_digits_squared += DIGITS_SQUARED[number % 1_0_0_0_0_0]
						number //= 1_0_0_0_0_0

			return sum_of_digits_squared


# There are 2 Chains made,
# One ends with 89 with the chain member 58 being the one which when declared first,
# there will be the least number of iterations for all the members to be checked.

# The other one ends with 1 and has only one element 1.

# So 58 and 1 are chosen to be declared at the starting.

# Changed dictionary to an array to quicken the solution
_UpperCamelCase						:						list[bool | None]  =					[None] * 10_000_000
_UpperCamelCase						:						List[str]  =					True
_UpperCamelCase						:						Tuple  =					False
def __UpperCAmelCase   (					A					:			int		)    ->   bool:

			if CHAINS[number - 1] is not None:
						return CHAINS[number - 1]  # type: ignore

			UpperCAmelCase_      :       Dict          =       chain(next_number(A		)		)
			UpperCAmelCase_      :       int          =       number_chain

			while number < 1_0_0_0_0_0_0_0:
						UpperCAmelCase_      :       Optional[Any]          =       number_chain
						number *= 1_0

			return number_chain
def __UpperCAmelCase   (					A					:			int = 1_0_0_0_0_0_0_0		)    ->   int:
			for i in range(1			,       A		):
						if CHAINS[i] is None:
									chain(i + 1		)

			return CHAINS[:number].count(A		)


if __name__ == "__main__":
						import doctest

						doctest.testmod()
						print(f'''{solution() = }''')


