






from __future__ import annotations




def 					lowercase__				(					__snake_case   :							int      ,	__snake_case   :							int  ):


					'''simple docstring'''


					UpperCAmelCase_   :				list[list[int]]						=						[]
					create_all_state(1      ,	__snake_case      ,	__snake_case      ,	[]      ,	__snake_case  )
					return result




def 					lowercase__				(					__snake_case   :							int      ,	__snake_case   :							int      ,	__snake_case   :							int      ,	__snake_case   :							list[int]      ,	__snake_case   :							list[list[int]]      ,	):


					'''simple docstring'''


					if level == 0:
										total_list.append(current_list[:]  )
										return

					for i in range(__snake_case      ,	total_number - level + 2  ):
										current_list.append(__snake_case  )
										create_all_state(i + 1      ,	__snake_case      ,	level - 1      ,	__snake_case      ,	__snake_case  )
										current_list.pop()




def 					lowercase__				(					__snake_case   :							list[list[int]]  ):


					'''simple docstring'''


					for i in total_list:
										print(*__snake_case  )


if __name__ == "__main__":
		__UpperCAmelCase     							=						4
		__UpperCAmelCase     							=						2
		__UpperCAmelCase     							=						generate_all_combinations(n, k)
		print_all_state(total_list)














def 					lowercase__				(					__snake_case   :							Tuple					,	__snake_case   :							List[Any]  ):


					'''simple docstring'''


					UpperCAmelCase_   :				Any						=						''
					for i in table:
										res += inp[i - 1]
					return res




def 					lowercase__				(					__snake_case   :							Optional[int]  ):


					'''simple docstring'''


					return data[1:] + data[0]




def 					lowercase__				(					__snake_case   :							Union[str, Any]					,	__snake_case   :							Optional[int]  ):


					'''simple docstring'''


					UpperCAmelCase_   :				Any						=						''
					for i in range(len(__snake_case  )  ):
										if a[i] == b[i]:
															res += "0"
										else:
															res += "1"
					return res




def 					lowercase__				(					__snake_case   :							Dict					,	__snake_case   :							Optional[int]  ):


					'''simple docstring'''


					UpperCAmelCase_   :				Optional[Any]						=						int('0b' + data[0] + data[-1]					,	2  )
					UpperCAmelCase_   :				Any						=						int('0b' + data[1:3]					,	2  )
					return bin(s[row][col]  )[2:]




def 					lowercase__				(					__snake_case   :							Tuple					,	__snake_case   :							List[Any]					,	__snake_case   :							List[Any]					,	__snake_case   :							Optional[int]					,	__snake_case   :							str  ):


					'''simple docstring'''


					UpperCAmelCase_   :				Union[str, Any]						=						message[:4]
					UpperCAmelCase_   :				Optional[int]						=						message[4:]
					UpperCAmelCase_   :				Union[str, Any]						=						apply_table(__snake_case					,	__snake_case  )
					UpperCAmelCase_   :				Union[str, Any]						=						xor(__snake_case					,	__snake_case  )
					UpperCAmelCase_   :				Dict						=						apply_sbox(__snake_case					,	temp[:4]  )  # noqa: E741
					UpperCAmelCase_   :				Any						=						apply_sbox(__snake_case					,	temp[4:]  )
					UpperCAmelCase_   :				str						=						'0' * (2 - len(__snake_case  )) + l  # noqa: E741
					UpperCAmelCase_   :				int						=						'0' * (2 - len(__snake_case  )) + r
					UpperCAmelCase_   :				int						=						apply_table(l + r					,	__snake_case  )
					UpperCAmelCase_   :				int						=						xor(__snake_case					,	__snake_case  )
					return temp + right


if __name__ == "__main__":
		__UpperCAmelCase     							=						input('Enter 10 bit key: ')
		__UpperCAmelCase     							=						input('Enter 8 bit message: ')

		__UpperCAmelCase     							=						[6, 3, 7, 4, 8, 5, 10, 9]
		__UpperCAmelCase     							=						[3, 5, 2, 7, 4, 10, 1, 9, 8, 6]
		__UpperCAmelCase     							=						[2, 4, 3, 1]
		__UpperCAmelCase     							=						[2, 6, 3, 1, 4, 8, 5, 7]
		__UpperCAmelCase     							=						[4, 1, 3, 5, 7, 2, 8, 6]
		__UpperCAmelCase     							=						[4, 1, 2, 3, 2, 3, 4, 1]
		__UpperCAmelCase     							=						[[1, 0, 3, 2], [3, 2, 1, 0], [0, 2, 1, 3], [3, 1, 3, 2]]
		__UpperCAmelCase     							=						[[0, 1, 2, 3], [2, 0, 1, 3], [3, 0, 1, 0], [2, 1, 0, 3]]

		# key generation
		__UpperCAmelCase     							=						apply_table(key, paa_table)
		__UpperCAmelCase     							=						temp[:5]
		__UpperCAmelCase     							=						temp[5:]
		__UpperCAmelCase     							=						left_shift(left)
		__UpperCAmelCase     							=						left_shift(right)
		__UpperCAmelCase     							=						apply_table(left + right, pa_table)
		__UpperCAmelCase     							=						left_shift(left)
		__UpperCAmelCase     							=						left_shift(right)
		__UpperCAmelCase     							=						left_shift(left)
		__UpperCAmelCase     							=						left_shift(right)
		__UpperCAmelCase     							=						apply_table(left + right, pa_table)

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

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






