<p>You are given a square <code>board</code>&nbsp;of characters. You can move on the board starting at the bottom right square marked with the character&nbsp;<code>&#39;S&#39;</code>.</p>

<p>You need&nbsp;to reach the top left square marked with the character <code>&#39;E&#39;</code>. The rest of the squares are labeled either with a numeric character&nbsp;<code>1, 2, ..., 9</code> or with an obstacle <code>&#39;X&#39;</code>. In one move you can go up, left or up-left (diagonally) only if there is no obstacle there.</p>

<p>Return a list of two integers: the first integer is the maximum sum of numeric characters you can collect, and the second is the number of such paths that you can take to get that maximum sum, <strong>taken modulo <code>10^9 + 7</code></strong>.</p>

<p>In case there is no path, return&nbsp;<code>[0, 0]</code>.</p>

<p>&nbsp;</p>
<p><strong class="example">Example 1:</strong></p>
<pre><strong>Input:</strong> board = ["E23","2X2","12S"]
<strong>Output:</strong> [7,1]
</pre><p><strong class="example">Example 2:</strong></p>
<pre><strong>Input:</strong> board = ["E12","1X1","21S"]
<strong>Output:</strong> [4,2]
</pre><p><strong class="example">Example 3:</strong></p>
<pre><strong>Input:</strong> board = ["E11","XXX","11S"]
<strong>Output:</strong> [0,0]
</pre>
<p>&nbsp;</p>
<p><strong>Constraints:</strong></p>

<ul>
	<li><code>2 &lt;= board.length == board[i].length &lt;= 100</code></li>
</ul>
class Solution:
    def pathsWithMaxScore(self, board: List[str]) -> List[int]:
        MOD = 10**9 + 7
        n = len(board)
        
        # Initialize dp table
        dp = [[(0, 0) for _ in range(n)] for _ in range(n)]
        dp[n-1][n-1] = (0, 1)  # Start at 'S' with sum 0 and 1 path
        
        # Iterate from bottom-right to top-left
        for i in range(n-1, -1, -1):
            for j in range(n-1, -1, -1):
                if board[i][j] == 'X' or (i == n-1 and j == n-1):
                    continue
                
                current_value = 0 if board[i][j] in 'SE' else int(board[i][j])
                
                # Check possible moves: down (i+1, j), right (i, j+1), diagonal (i+1, j+1)
                max_sum, num_paths = 0, 0
                for ni, nj in [(i+1, j), (i, j+1), (i+1, j+1)]:
                    if 0 <= ni < n and 0 <= nj < n:
                        prev_sum, prev_paths = dp[ni][nj]
                        if prev_paths > 0:  # If there's a valid path from this cell
                            if prev_sum + current_value > max_sum:
                                max_sum = prev_sum + current_value
                                num_paths = prev_paths
                            elif prev_sum + current_value == max_sum:
                                num_paths = (num_paths + prev_paths) % MOD
                
                dp[i][j] = (max_sum, num_paths)
        
        return list(dp[0][0])
18000