


'''simple docstring'''




class 			_lowercase :
   def __init__(						self       :      Any      ) ->							Union[str, Any]:
        __snake_case           =						''
        __snake_case           =						''
        __snake_case           =						[]
   def a  (						self       :      Union[str, Any]       ,   SCREAMING_SNAKE_CASE_       :      int       ,   SCREAMING_SNAKE_CASE_       :      int      ) ->							int:
        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]:
                  __snake_case           =						self.__min_dist_top_down_dp(m - 1       ,   n - 1      )
             else:
                  __snake_case           =						self.__min_dist_top_down_dp(SCREAMING_SNAKE_CASE_       ,   n - 1      )
                  __snake_case           =						self.__min_dist_top_down_dp(m - 1       ,   SCREAMING_SNAKE_CASE_      )
                  __snake_case           =						self.__min_dist_top_down_dp(m - 1       ,   n - 1      )
                  __snake_case           =						1 + min(SCREAMING_SNAKE_CASE_       ,   SCREAMING_SNAKE_CASE_       ,   SCREAMING_SNAKE_CASE_      )

             return self.dp[m][n]
   def a  (						self       :      Tuple       ,   SCREAMING_SNAKE_CASE_       :      str       ,   SCREAMING_SNAKE_CASE_       :      str      ) ->							int:
        __snake_case           =						worda
        __snake_case           =						worda
        __snake_case           =						[[-1 for _ in range(len(SCREAMING_SNAKE_CASE_      )      )] for _ in range(len(SCREAMING_SNAKE_CASE_      )      )]

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





   def a  (						self       :      Any       ,   SCREAMING_SNAKE_CASE_       :      str       ,   SCREAMING_SNAKE_CASE_       :      str      ) ->							int:
        __snake_case           =						worda
        __snake_case           =						worda
        __snake_case           =						len(SCREAMING_SNAKE_CASE_      )
        __snake_case           =						len(SCREAMING_SNAKE_CASE_      )
        __snake_case           =						[[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
                       __snake_case           =						j
                  elif j == 0:  # second string is empty
                       __snake_case           =						i
                  elif worda[i - 1] == worda[j - 1]:  # last characters are equal
                       __snake_case           =						self.dp[i - 1][j - 1]
                  else:
                       __snake_case           =						self.dp[i][j - 1]
                       __snake_case           =						self.dp[i - 1][j]
                       __snake_case           =						self.dp[i - 1][j - 1]
                       __snake_case           =						1 + min(SCREAMING_SNAKE_CASE_       ,   SCREAMING_SNAKE_CASE_       ,   SCREAMING_SNAKE_CASE_      )
        return self.dp[m][n]


if __name__ == "__main__":
       _a   :   Optional[Any]												=   EditDistance()

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

       _a   :   Any												=   input("Enter the first string: ").strip()
       _a   :   str												=   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 ***************")








"""simple docstring"""

def lowerCAmelCase_   (					UpperCamelCase__						:			Union[str, Any]					, UpperCamelCase__						:			Union[str, Any]					, UpperCamelCase__						:			int			):






 """simple docstring"""







 if n == 0:
  return 1

 elif n % 2 == 1:
  return (binary_exponentiation(UpperCamelCase__					, n - 1					, UpperCamelCase__			) * a) % mod

 else:
  __lowercase						=						binary_exponentiation(UpperCamelCase__					, n / 2					, UpperCamelCase__			)
  return (b * b) % mod


# a prime number
UpperCAmelCase__					=701

UpperCAmelCase__					=10_0000_0000
UpperCAmelCase__					=10

# using binary exponentiation function, O(log(p)):
print((a / b) % p == (a * binary_exponentiation(b, p - 2, p)) % p)

print((a / b) % p == (a * b ** (p - 2)) % p)
