


from __future__ import annotations


class   a__	:

       def __init__(   self      :     Optional[int]      ,							lowerCamelCase_      :     int = 0    ):
            a_    :     str										=    key

       def 						UpperCAmelCase(   self      :     Optional[Any]      ,							lowerCamelCase_      :     str      ,							lowerCamelCase_      :     int    ):
            assert isinstance(lowerCamelCase_      ,							lowerCamelCase_    ) and isinstance(lowerCamelCase_      ,							lowerCamelCase_    )

            a_    :     Tuple										=    key or self.__key or 1

            # make sure key is an appropriate size
            key %= 2_5_5

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

       def 						UpperCAmelCase(   self      :     List[str]      ,							lowerCamelCase_      :     str      ,							lowerCamelCase_      :     int    ):
            assert isinstance(lowerCamelCase_      ,							lowerCamelCase_    ) and isinstance(lowerCamelCase_      ,							lowerCamelCase_    )

            a_    :     str										=    key or self.__key or 1

            # make sure key is an appropriate size
            key %= 2_5_5

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

       def 						UpperCAmelCase(   self      :     List[Any]      ,							lowerCamelCase_      :     str      ,							lowerCamelCase_      :     int = 0    ):
            assert isinstance(lowerCamelCase_      ,							lowerCamelCase_    ) and isinstance(lowerCamelCase_      ,							lowerCamelCase_    )

            a_    :     Optional[int]										=    key or self.__key or 1

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

            # This will be returned
            a_    :     Optional[int]										=    """"""

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

            return ans

       def 						UpperCAmelCase(   self      :     int      ,							lowerCamelCase_      :     str      ,							lowerCamelCase_      :     int = 0    ):
            assert isinstance(lowerCamelCase_      ,							lowerCamelCase_    ) and isinstance(lowerCamelCase_      ,							lowerCamelCase_    )

            a_    :     List[Any]										=    key or self.__key or 1

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

            # This will be returned
            a_    :     Dict										=    """"""

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

            return ans

       def 						UpperCAmelCase(   self      :     int      ,							lowerCamelCase_      :     str      ,							lowerCamelCase_      :     int = 0    ):
            assert isinstance(lowerCamelCase_      ,							lowerCamelCase_    ) and isinstance(lowerCamelCase_      ,							lowerCamelCase_    )

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

            except OSError:
                 return False

            return True

       def 						UpperCAmelCase(   self      :     List[Any]      ,							lowerCamelCase_      :     str      ,							lowerCamelCase_      :     int    ):
            assert isinstance(lowerCamelCase_      ,							lowerCamelCase_    ) and isinstance(lowerCamelCase_      ,							lowerCamelCase_    )

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

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







from heapq import heappop, heappush

import numpy as np



def  _a			(						__UpperCamelCase  ,  __UpperCamelCase  ,  __UpperCamelCase  ,  __UpperCamelCase  ,  ):
     a_			,			a_    :     Any										=    grid.shape
     a_    :     Dict										=    [-1, 1, 0, 0]
     a_    :     List[Any]										=    [0, 0, -1, 1]
     if allow_diagonal:
          dx += [-1, -1, 1, 1]
          dy += [-1, 1, -1, 1]

     a_			,			a_    :     int										=    [(0, source)], set()
     a_    :     Optional[Any]										=    np.full((rows, cols)  ,  np.inf )
     a_    :     Tuple										=    0
     a_    :     Optional[Any]										=    np.empty((rows, cols)  ,  dtype=__UpperCamelCase )
     a_    :     Optional[Any]										=    None

     while queue:
          ((a_)			,			(a_))    :     Any										=    heappop(__UpperCamelCase )
          if (x, y) in visited:
               continue
          visited.add((x, y) )

          if (x, y) == destination:
               a_    :     Tuple										=    []
               while (x, y) != source:
                    path.append((x, y) )
                    a_			,			a_    :     Any										=    predecessors[x, y]
               path.append(__UpperCamelCase )  # add the source manually
               path.reverse()
               return matrix[destination], path

          for i in range(len(__UpperCamelCase ) ):
               a_			,			a_    :     Dict										=    x + dx[i], y + dy[i]
               if 0 <= nx < rows and 0 <= ny < cols:
                    a_    :     List[Any]										=    grid[nx][ny]
                    if next_node == 1 and matrix[nx, ny] > dist + 1:
                         heappush(__UpperCamelCase  ,  (dist + 1, (nx, ny)) )
                         a_    :     List[str]										=    dist + 1
                         a_    :     Union[str, Any]										=    (x, y)

     return np.inf, []


if __name__ == "__main__":
       import doctest

       doctest.testmod()



