input: from typing import List
  
  def transform_matrix(matrix: List[List[int]]) -> List[List[int]]:
      """
      Given a 0-indexed m x n integer matrix, generate a new 0-indexed matrix called result. Start with result equal to matrix, and then for any element with the value -1, replace it with the maximum element in its respective column.
  
      Return the matrix result.
  
      Examples:
      >>> matrix = [[1,2,-1],[4,-1,6],[7,8,9]]
      [[1,2,9],[4,8,6],[7,8,9]]
      >>> matrix = [[3,-1],[5,2]]
      [[3,2],[5,2]]
  
      Constraints:
      m == len(matrix)
      n == len(matrix[i])
      2 <= m, n <= 50
      -1 <= matrix[i][j] <= 100
      The input is guaranteed such that each column has at least one non-negative integer.
      """
output:     
      # Find the dimensions of the matrix
      m = len(matrix)
      n = len(matrix[0])
  
      # Initialize a list to store the maximum values of each column
      max_in_column = [-1] * n
  
      # Determine the maximum value for each column
      for j in range(n):
          max_in_column[j] = max(matrix[i][j] for i in range(m) if matrix[i][j] != -1)
  
      # Create the result matrix by replacing -1's with their column's max value
      result = [
          [
              max_in_column[j] if matrix[i][j] == -1 else matrix[i][j]
              for j in range(n)
          ]
          for i in range(m)
      ]
  
      return result
  