


"""simple docstring"""







import heapq as hq
import math
from collections.abc import Iterator






class 				__A    :






 """simple docstring"""




 def __init__(		self			,   __A						) ->					Any:
     a					=str(id_						)
     a					=None
     a					=None
     a					=[]
     a					={}  # {vertex:distance}


 def __lt__(		self			,   __A						) ->					Tuple:
     return self.key < other.key


 def __repr__(		self						) ->					List[Any]:
     return self.id


 def 				SCREAMING_SNAKE_CASE							(		self			,   __A						) ->					List[Any]:
     self.neighbors.append(__UpperCAmelCase						)





 def 				SCREAMING_SNAKE_CASE							(		self			,   __A			,   __A						) ->					List[str]:
     a					=weight

def _A						(						lowercase	,   lowercase	,   lowercase	,   lowercase		):







    """simple docstring"""
    graph[a - 1].add_neighbor(graph[b - 1]		)
    graph[b - 1].add_neighbor(graph[a - 1]		)
    # add the edges:
    graph[a - 1].add_edge(graph[b - 1]	,   lowerCAmelCase__		)
    graph[b - 1].add_edge(graph[a - 1]	,   lowerCAmelCase__		)
def _A						(						lowercase	,   lowercase		):







    """simple docstring"""
    a					=[]
    for u in graph:
        a					=math.inf
        a					=None
    a					=0
    a					=graph[:]
    while q:
        a					=min(lowerCAmelCase__		)
        q.remove(lowerCAmelCase__		)
        for v in u.neighbors:
            if (v in q) and (u.edges[v.id] < v.key):
                a					=u
                a					=u.edges[v.id]
    for i in range(1	,   len(lowerCAmelCase__		)		):
        a.append((int(graph[i].id		) + 1, int(graph[i].pi.id		) + 1)		)
    return a
def _A						(						lowercase	,   lowercase		):







    """simple docstring"""





    for u in graph:
        a					=math.inf
        a					=None
    a					=0

    a					=list(lowerCAmelCase__		)
    hq.heapify(lowerCAmelCase__		)

    while h:
        a					=hq.heappop(lowerCAmelCase__		)
        for v in u.neighbors:
            if (v in h) and (u.edges[v.id] < v.key):
                a					=u
                a					=u.edges[v.id]
                hq.heapify(lowerCAmelCase__		)

    for i in range(1	,   len(lowerCAmelCase__		)		):
        yield (int(graph[i].id		) + 1, int(graph[i].pi.id		) + 1)
def _A						(						):







    """simple docstring"""







if __name__ == "__main__":
       import doctest

       doctest.testmod()



"""simple docstring"""







from __future__ import annotations






class 				__A    :






 """simple docstring"""




 def __init__(		self			,   __A = 0						) ->					Dict:
     a					=key


 def 				SCREAMING_SNAKE_CASE							(		self			,   __A			,   __A						) ->					list[str]:
     assert isinstance(__A			,   __A						) and isinstance(__A			,   __A						)

     a					=key or self.__key or 1

     # make sure key is an appropriate size
     key %= 255

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


 def 				SCREAMING_SNAKE_CASE							(		self			,   __A			,   __A						) ->					list[str]:
     assert isinstance(__A			,   __A						) and isinstance(__A			,   __A						)

     a					=key or self.__key or 1

     # make sure key is an appropriate size
     key %= 255

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


 def 				SCREAMING_SNAKE_CASE							(		self			,   __A			,   __A = 0						) ->					str:
     assert isinstance(__A			,   __A						) and isinstance(__A			,   __A						)

     a					=key or self.__key or 1

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

     # This will be returned
     a					=''''''

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

     return ans


 def 				SCREAMING_SNAKE_CASE							(		self			,   __A			,   __A = 0						) ->					str:
     assert isinstance(__A			,   __A						) and isinstance(__A			,   __A						)

     a					=key or self.__key or 1

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

     # This will be returned
     a					=''''''

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

     return ans


 def 				SCREAMING_SNAKE_CASE							(		self			,   __A			,   __A = 0						) ->					bool:
     assert isinstance(__A			,   __A						) and isinstance(__A			,   __A						)

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

     except OSError:
         return False

     return True





 def 				SCREAMING_SNAKE_CASE							(		self			,   __A			,   __A						) ->					bool:
     assert isinstance(__A			,   __A						) and isinstance(__A			,   __A						)

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

     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")