





class        SCREAMING_SNAKE_CASE     :


   def __init__(					self    :       List[Any] )->     Dict:





     """simple docstring"""







     lowercase__			    =						''
     lowercase__			    =						''
     lowercase__			    =						[]


   def  SCREAMING_SNAKE_CASE_							(					self    :       List[str]    ,  a    :       int    ,  a    :       int )->     int:





     """simple docstring"""







     if m == -1:
       return n + 1
     elif n == -1:
       return m + 1
     elif self.dp[m][n] > -1:
       return self.dp[m][n]
     else:
       if self.worda[m] == self.worda[n]:
         lowercase__			    =						self.__min_dist_top_down_dp(m - 1    ,  n - 1 )
       else:
         lowercase__			    =						self.__min_dist_top_down_dp(a    ,  n - 1 )
         lowercase__			    =						self.__min_dist_top_down_dp(m - 1    ,  a )
         lowercase__			    =						self.__min_dist_top_down_dp(m - 1    ,  n - 1 )
         lowercase__			    =						1 + min(a    ,  a    ,  a )

       return self.dp[m][n]


   def  SCREAMING_SNAKE_CASE_							(					self    :       Optional[int]    ,  a    :       str    ,  a    :       str )->     int:





     """simple docstring"""







     lowercase__			    =						worda
     lowercase__			    =						worda
     lowercase__			    =						[[-1 for _ in range(len(a ) )] for _ in range(len(a ) )]

     return self.__min_dist_top_down_dp(len(a ) - 1    ,  len(a ) - 1 )


   def  SCREAMING_SNAKE_CASE_							(					self    :       Optional[int]    ,  a    :       str    ,  a    :       str )->     int:





     """simple docstring"""







     lowercase__			    =						worda
     lowercase__			    =						worda
     lowercase__			    =						len(a )
     lowercase__			    =						len(a )
     lowercase__			    =						[[0 for _ in range(n + 1 )] for _ in range(m + 1 )]

     for i in range(m + 1 ):
       for j in range(n + 1 ):
         if i == 0:  # first string is empty
           lowercase__			    =						j
         elif j == 0:  # second string is empty
           lowercase__			    =						i
         elif worda[i - 1] == worda[j - 1]:  # last characters are equal
           lowercase__			    =						self.dp[i - 1][j - 1]
         else:
           lowercase__			    =						self.dp[i][j - 1]
           lowercase__			    =						self.dp[i - 1][j]
           lowercase__			    =						self.dp[i - 1][j - 1]
           lowercase__			    =						1 + min(a    ,  a    ,  a )
     return self.dp[m][n]


if __name__ == "__main__":
      lowercase_					     =	EditDistance()

      print("""****************** Testing Edit Distance DP Algorithm ******************""")
      print()

      lowercase_					     =	input("""Enter the first string: """).strip()
      lowercase_					     =	input("""Enter the second string: """).strip()

      print()
      print(f'''The minimum edit distance is: {solver.min_dist_top_down(Sa, Sa)}''')
      print(f'''The minimum edit distance is: {solver.min_dist_bottom_up(Sa, Sa)}''')
      print()
      print("""*************** End of Testing Edit Distance DP Algorithm ***************""")









class        SCREAMING_SNAKE_CASE     :  # Public class to implement a graph


   def __init__(					self    :       int    ,  a    :       int    ,  a    :       int    ,  a    :       list[list[bool]] )->     None:





     """simple docstring"""







     lowercase__			    =						row
     lowercase__			    =						col
     lowercase__			    =						graph


   def  SCREAMING_SNAKE_CASE_							(					self    :       Dict    ,  a    :       int    ,  a    :       int    ,  a    :       list[list[bool]] )->     bool:





     """simple docstring"""







     return (
         0 <= i < self.ROW
         and 0 <= j < self.COL
         and not visited[i][j]
         and self.graph[i][j]
     )


   def  SCREAMING_SNAKE_CASE_							(					self    :       List[str]    ,  a    :       int    ,  a    :       int    ,  a    :       list[list[bool]] )->     None:





     """simple docstring"""







     lowercase__			    =						[-1, -1, -1, 0, 0, 1, 1, 1]  # Coordinate order
     lowercase__			    =						[-1, 0, 1, -1, 1, -1, 0, 1]
     lowercase__			    =						True  # Make those cells visited
     for k in range(8 ):
       if self.is_safe(i + row_nbr[k]    ,  j + col_nbr[k]    ,  a ):
         self.diffs(i + row_nbr[k]    ,  j + col_nbr[k]    ,  a )


   def  SCREAMING_SNAKE_CASE_							(					self    :       List[str] )->     int:  # And finally, count all islands.





     """simple docstring"""







     lowercase__			    =						[[False for j in range(self.COL )] for i in range(self.ROW )]
     lowercase__			    =						0
     for i in range(self.ROW ):
       for j in range(self.COL ):
         if visited[i][j] is False and self.graph[i][j] == 1:
           self.diffs(a    ,  a    ,  a )
           count += 1
     return count


