

def 			A_      (    _UpperCAmelCase				,	_UpperCAmelCase    ):
						SCREAMING_SNAKE_CASE_: Any  		=       ""
						for i in table:
												res += inp[i - 1]
						return res







def 			A_      (    _UpperCAmelCase    ):
						return data[1:] + data[0]







def 			A_      (    _UpperCAmelCase				,	_UpperCAmelCase    ):
						SCREAMING_SNAKE_CASE_: Optional[Any]  		=       ""
						for i in range(len(_UpperCAmelCase    )    ):
												if a[i] == b[i]:
																		res += "0"
												else:
																		res += "1"
						return res







def 			A_      (    _UpperCAmelCase				,	_UpperCAmelCase    ):
						SCREAMING_SNAKE_CASE_: Dict  		=       int("0b" + data[0] + data[-1]				,	2    )
						SCREAMING_SNAKE_CASE_: List[str]  		=       int("0b" + data[1:3]				,	2    )
						return bin(s[row][col]    )[2:]







def 			A_      (    _UpperCAmelCase				,	_UpperCAmelCase				,	_UpperCAmelCase				,	_UpperCAmelCase				,	_UpperCAmelCase    ):
						SCREAMING_SNAKE_CASE_: Optional[Any]  		=       message[:4]
						SCREAMING_SNAKE_CASE_: int  		=       message[4:]
						SCREAMING_SNAKE_CASE_: Any  		=       apply_table(_UpperCAmelCase				,	_UpperCAmelCase    )
						SCREAMING_SNAKE_CASE_: List[Any]  		=       xor(_UpperCAmelCase				,	_UpperCAmelCase    )
						SCREAMING_SNAKE_CASE_: Any  		=       apply_sbox(_UpperCAmelCase				,	temp[:4]    )  # noqa: E741
						SCREAMING_SNAKE_CASE_: Any  		=       apply_sbox(_UpperCAmelCase				,	temp[4:]    )
						SCREAMING_SNAKE_CASE_: str  		=       "0" * (2 - len(_UpperCAmelCase    )) + l  # noqa: E741
						SCREAMING_SNAKE_CASE_: Union[str, Any]  		=       "0" * (2 - len(_UpperCAmelCase    )) + r
						SCREAMING_SNAKE_CASE_: Any  		=       apply_table(l + r				,	_UpperCAmelCase    )
						SCREAMING_SNAKE_CASE_: List[Any]  		=       xor(_UpperCAmelCase				,	_UpperCAmelCase    )
						return temp + right


if __name__ == "__main__":
						lowerCAmelCase							:  List[Any]   	=						input("""Enter 10 bit key: """)
						lowerCAmelCase							:  List[str]   	=						input("""Enter 8 bit message: """)

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

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

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

						# decryption
						lowerCAmelCase							:  int   	=						apply_table(CT, IP)
						lowerCAmelCase							:  Optional[int]   	=						function(expansion, sa, sa, keya, temp)
						lowerCAmelCase							:  Dict   	=						temp[4:] + temp[:4]
						lowerCAmelCase							:  Optional[Any]   	=						function(expansion, sa, sa, keya, temp)
						lowerCAmelCase							:  Dict   	=						apply_table(temp, IP_inv)
						print("""Plain text after decypting is:""", PT)









class   __lowercase				:




			"""simple docstring"""







			def __init__( self  :     List[Any]   ,						lowerCAmelCase__  :     Optional[int]   ,						lowerCAmelCase__  :     List[Any]):
									SCREAMING_SNAKE_CASE_: List[str]  		=       name
									SCREAMING_SNAKE_CASE_: Union[str, Any]  		=       val



			def __str__( self  :     Dict):
									return F"{self.__class__.__name__}({self.name}, {self.val})"




			def __lt__( self  :     List[str]   ,						lowerCAmelCase__  :     Any):
									return self.val < other.val







class   __lowercase				:




			"""simple docstring"""







			def __init__( self  :     Tuple   ,						lowerCAmelCase__  :     Dict):
									SCREAMING_SNAKE_CASE_: str  		=       {}
									SCREAMING_SNAKE_CASE_: int  		=       {}
									SCREAMING_SNAKE_CASE_: Any  		=       self.build_heap(lowerCAmelCase__)



			def __getitem__( self  :     List[Any]   ,						lowerCAmelCase__  :     Dict):
									return self.get_value(lowerCAmelCase__)



			def        _SCREAMING_SNAKE_CASE			( self  :     Optional[Any]   ,						lowerCAmelCase__  :     Dict):
									return (idx - 1) // 2



			def        _SCREAMING_SNAKE_CASE			( self  :     Union[str, Any]   ,						lowerCAmelCase__  :     Optional[Any]):
									return idx * 2 + 1



			def        _SCREAMING_SNAKE_CASE			( self  :     Optional[int]   ,						lowerCAmelCase__  :     Tuple):
									return idx * 2 + 2



			def        _SCREAMING_SNAKE_CASE			( self  :     Optional[int]   ,						lowerCAmelCase__  :     Optional[int]):
									return self.heap_dict[key]



			def        _SCREAMING_SNAKE_CASE			( self  :     List[Any]   ,						lowerCAmelCase__  :     Union[str, Any]):
									SCREAMING_SNAKE_CASE_: Tuple  		=       len(lowerCAmelCase__) - 1
									SCREAMING_SNAKE_CASE_: List[str]  		=       self.get_parent_idx(lowerCAmelCase__)

									for idx, i in enumerate(lowerCAmelCase__):
															SCREAMING_SNAKE_CASE_: Union[str, Any]  		=       idx
															SCREAMING_SNAKE_CASE_: str  		=       i.val

									for i in range(lowerCAmelCase__   ,						-1   ,						-1):
															self.sift_down(lowerCAmelCase__   ,						lowerCAmelCase__)
									return array



			def        _SCREAMING_SNAKE_CASE			( self  :     str   ,						lowerCAmelCase__  :     Optional[int]   ,						lowerCAmelCase__  :     List[str]):
									while True:
															SCREAMING_SNAKE_CASE_: Optional[Any]  		=       self.get_left_child_idx(lowerCAmelCase__)  # noqa: E741
															SCREAMING_SNAKE_CASE_: Dict  		=       self.get_right_child_idx(lowerCAmelCase__)

															SCREAMING_SNAKE_CASE_: int  		=       idx
															if l < len(lowerCAmelCase__) and array[l] < array[idx]:
																					SCREAMING_SNAKE_CASE_: List[str]  		=       l
															if r < len(lowerCAmelCase__) and array[r] < array[smallest]:
																					SCREAMING_SNAKE_CASE_: str  		=       r

															if smallest != idx:
																					SCREAMING_SNAKE_CASE_		,    SCREAMING_SNAKE_CASE_: Any  		=       array[smallest], array[idx]
																					(
																					    (
																					    SCREAMING_SNAKE_CASE_
																					)		,    (
																					    SCREAMING_SNAKE_CASE_
																					)		,    
																					): Optional[Any]  		=       (
																					    self.idx_of_element[array[smallest]],
																					    self.idx_of_element[array[idx]],
																					)
																					SCREAMING_SNAKE_CASE_: Optional[int]  		=       smallest
															else:
																					break



			def        _SCREAMING_SNAKE_CASE			( self  :     Dict   ,						lowerCAmelCase__  :     str):
									SCREAMING_SNAKE_CASE_: Any  		=       self.get_parent_idx(lowerCAmelCase__)
									while p >= 0 and self.heap[p] > self.heap[idx]:
															SCREAMING_SNAKE_CASE_		,    SCREAMING_SNAKE_CASE_: List[Any]  		=       self.heap[idx], self.heap[p]
															SCREAMING_SNAKE_CASE_		,    SCREAMING_SNAKE_CASE_: Tuple  		=       (
															    self.idx_of_element[self.heap[idx]],
															    self.idx_of_element[self.heap[p]],
															)
															SCREAMING_SNAKE_CASE_: Union[str, Any]  		=       p
															SCREAMING_SNAKE_CASE_: Optional[int]  		=       self.get_parent_idx(lowerCAmelCase__)



			def        _SCREAMING_SNAKE_CASE			( self  :     List[Any]):
									return self.heap[0]



			def        _SCREAMING_SNAKE_CASE			( self  :     Dict):
									SCREAMING_SNAKE_CASE_		,    SCREAMING_SNAKE_CASE_: Tuple  		=       self.heap[-1], self.heap[0]
									SCREAMING_SNAKE_CASE_		,    SCREAMING_SNAKE_CASE_: List[str]  		=       (
									    self.idx_of_element[self.heap[-1]],
									    self.idx_of_element[self.heap[0]],
									)

									SCREAMING_SNAKE_CASE_: int  		=       self.heap.pop()
									del self.idx_of_element[x]
									self.sift_down(0   ,						self.heap)
									return x



			def        _SCREAMING_SNAKE_CASE			( self  :     Union[str, Any]   ,						lowerCAmelCase__  :     Tuple):
									self.heap.append(lowerCAmelCase__)
									SCREAMING_SNAKE_CASE_: List[str]  		=       len(self.heap) - 1
									SCREAMING_SNAKE_CASE_: List[str]  		=       node.val
									self.sift_up(len(self.heap) - 1)



			def        _SCREAMING_SNAKE_CASE			( self  :     List[Any]):
									return len(self.heap) == 0




			def        _SCREAMING_SNAKE_CASE			( self  :     Optional[Any]   ,						lowerCAmelCase__  :     Any   ,						lowerCAmelCase__  :     Optional[int]):
									assert (
									    self.heap[self.idx_of_element[node]].val > new_value
									), "newValue must be less that current value"
									SCREAMING_SNAKE_CASE_: Any  		=       new_value
									SCREAMING_SNAKE_CASE_: Tuple  		=       new_value
									self.sift_up(self.idx_of_element[node])







lowerCAmelCase							:  int   	=						Node("""R""", -1)
lowerCAmelCase							:  str   	=						Node("""B""", 6)
lowerCAmelCase							:  str   	=						Node("""A""", 3)
lowerCAmelCase							:  List[str]   	=						Node("""X""", 1)
lowerCAmelCase							:  Union[str, Any]   	=						Node("""E""", 4)

# Use one of these two ways to generate Min-Heap

# Generating Min-Heap from array
lowerCAmelCase							:  Optional[Any]   	=						MinHeap([r, b, a, x, e])

# Generating Min-Heap by Insert method
# myMinHeap.insert(a)
# myMinHeap.insert(b)
# myMinHeap.insert(x)
# myMinHeap.insert(r)
# myMinHeap.insert(e)

# Before
print("""Min Heap - before decrease key""")
for i in my_min_heap.heap:
						print(i)

print("""Min Heap - After decrease key of node [B -> -17]""")
my_min_heap.decrease_key(b, -17)

# After
for i in my_min_heap.heap:
						print(i)

if __name__ == "__main__":
						import doctest

						doctest.testmod()






