input: from typing import List
  
  def max_score_in_matrix(grid: List[List[int]]) -> int:
      """
      You are given an m x n matrix grid consisting of positive integers. You can move from a cell in the matrix to any other cell that is either to the bottom or to the right (not necessarily adjacent). The score of a move from a cell with the value c1 to a cell with the value c2 is c2 - c1.
  
      You can start at any cell, and you have to make at least one move.
  
      Return the maximum total score you can achieve.
  
      Examples:
      >>> grid = [[9,5,7,3],[8,9,6,1],[6,7,14,3],[2,5,3,1]]
      9
      >>> grid = [[4,3,2],[3,2,1]]
      -1
  
      Constraints:
      m == grid.length
      n == grid[i].length
      2 <= m, n <= 1000
      4 <= m * n <= 10^5
      1 <= grid[i][j] <= 10^5
      """
  
output: 
      m, n = len(grid), len(grid[0])
      dp = [[-float('inf')] * n for _ in range(m)]
      
      for i in range(m):
          for j in range(n):
              if i > 0:
                  dp[i][j] = max(dp[i][j], dp[i-1][j] + grid[i][j] - grid[i-1][j])
              if j > 0:
                  dp[i][j] = max(dp[i][j], dp[i][j-1] + grid[i][j] - grid[i][j-1])
              dp[i][j] = max(dp[i][j], grid[i][j])
      
      return max(max(row) for row in dp)
  