input: Write a python function to find the longest common substring between two given strings.
  assert LongestCommonSubstring("abcdef", "zabcg") == "abc"
  assert LongestCommonSubstring("apple pie", "maple syrup") == "ple"
  assert LongestCommonSubstring("12345", "54321") == "1"
output: def LongestCommonSubstring(str1, str2):
      def get_matrix(rows, cols):
          return [[0] * cols for _ in range(rows)]
  
      m, n = len(str1), len(str2)
      matrix = get_matrix(m + 1, n + 1)
      longest_length = 0
      end_index = 0
  
      for i in range(1, m + 1):
          for j in range(1, n + 1):
              if str1[i - 1] == str2[j - 1]:
                  matrix[i][j] = matrix[i - 1][j - 1] + 1
                  if matrix[i][j] > longest_length:
                      longest_length = matrix[i][j]
                      end_index = i
  
      return str1[end_index - longest_length:end_index]