


from __future__ import annotations

import os
from collections.abc import Mapping

lowerCAmelCase__			:      int								=tuple[int, int]







class 	__lowercase    :





							"""simple docstring"""







							def __init__(      self			,						lowerCAmelCase__			,						lowerCAmelCase__       ):





										"""simple docstring"""




										SCREAMING_SNAKE_CASE_		:     set[int]					=					vertices
										SCREAMING_SNAKE_CASE_		:     dict[EdgeT, int]					=					{
										    (min(lowerCAmelCase__       ), max(lowerCAmelCase__       )): weight for edge, weight in edges.items()
										}






							def 					UpperCamelCase__     (      self			,						lowerCAmelCase__			,						lowerCAmelCase__       ):





										"""simple docstring"""




										self.vertices.add(edge[0]       )
										self.vertices.add(edge[1]       )
										SCREAMING_SNAKE_CASE_		:     Tuple					=					weight






							def 					UpperCamelCase__     (      self       ):





										"""simple docstring"""




										SCREAMING_SNAKE_CASE_		:     Graph					=					Graph({min(self.vertices       )}			,						{}       )
										SCREAMING_SNAKE_CASE_		:     EdgeT
										SCREAMING_SNAKE_CASE_		:     int
										SCREAMING_SNAKE_CASE_		:     EdgeT
										SCREAMING_SNAKE_CASE_		:     int

										while len(subgraph.vertices       ) < len(self.vertices       ):
													SCREAMING_SNAKE_CASE_		:     List[Any]					=					max(self.edges.values()       ) + 1
													for edge, weight in self.edges.items():
																if (edge[0] in subgraph.vertices) ^ (edge[1] in subgraph.vertices):
																			if weight < min_weight:
																						SCREAMING_SNAKE_CASE_		:     Tuple					=					edge
																						SCREAMING_SNAKE_CASE_		:     Tuple					=					weight

													subgraph.add_edge(lowerCAmelCase__			,						lowerCAmelCase__       )

										return subgraph







def 						a__			(				A__ = "p107_network.txt"				):
			SCREAMING_SNAKE_CASE_		:     str					=					os.path.abspath(os.path.dirname(A__				)				)
			SCREAMING_SNAKE_CASE_		:     str					=					os.path.join(A__,      A__				)
			SCREAMING_SNAKE_CASE_		:     dict[EdgeT, int]					=					{}
			SCREAMING_SNAKE_CASE_		:     list[str]
			SCREAMING_SNAKE_CASE_		:     int
			SCREAMING_SNAKE_CASE_		:     int

			with open(A__				) as f:
						SCREAMING_SNAKE_CASE_		:     Dict					=					f.read().strip().split('\n'				)

			SCREAMING_SNAKE_CASE_		:     List[Any]					=					[line.split(','				) for line in data]

			for edgea in range(1,      len(A__				)				):
						for edgea in range(A__				):
									if adjaceny_matrix[edgea][edgea] != "-":
												SCREAMING_SNAKE_CASE_		:     Tuple					=					int(adjaceny_matrix[edgea][edgea]				)

			SCREAMING_SNAKE_CASE_		:     Graph					=					Graph(set(range(len(A__				)				)				),      A__				)

			SCREAMING_SNAKE_CASE_		:     Graph					=					graph.prims_algorithm()

			SCREAMING_SNAKE_CASE_		:     int					=					sum(graph.edges.values()				)
			SCREAMING_SNAKE_CASE_		:     int					=					sum(subgraph.edges.values()				)

			return initial_total - optimal_total


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









def 						a__			(				A__,      A__				):
			SCREAMING_SNAKE_CASE_		:     Optional[Any]					=					''
			for i in table:
						res += inp[i - 1]
			return res






def 						a__			(				A__				):
			return data[1:] + data[0]






def 						a__			(				A__,      A__				):
			SCREAMING_SNAKE_CASE_		:     Optional[int]					=					''
			for i in range(len(A__				)				):
						if a[i] == b[i]:
									res += "0"
						else:
									res += "1"
			return res






def 						a__			(				A__,      A__				):
			SCREAMING_SNAKE_CASE_		:     Tuple					=					int('0b' + data[0] + data[-1],      2				)
			SCREAMING_SNAKE_CASE_		:     Tuple					=					int('0b' + data[1:3],      2				)
			return bin(s[row][col]				)[2:]






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


if __name__ == "__main__":
				lowerCAmelCase__			:      Optional[Any]								=input('Enter 10 bit key: ')
				lowerCAmelCase__			:      int								=input('Enter 8 bit message: ')

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

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

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

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





