A ball starts at row startRow and column startColumn in a grid with m rows and n columns, using zero-based indices. Each move goes one cell up, down, left, or right. Count the different sequences of moves that take the ball outside the grid using at most maxMove moves. A path ends immediately when it first leaves the grid; do not extend or count it again afterward. Return the count modulo 1000000007.
Example 1:
Input: m = 1
n = 1
maxMove = 1
startRow = 0
startColumn = 0
Output: 4Explanation: The grid has one cell. Each of the four possible first moves immediately leaves it, giving four paths.
Example 2:
Input: m = 3
n = 3
maxMove = 1
startRow = 1
startColumn = 1
Output: 0Explanation: The ball starts at the center. Every first move lands on another cell inside the grid, so none of the paths exits within one move.
Example 3:
Input: m = 1
n = 2
maxMove = 2
startRow = 0
startColumn = 0
Output: 6Explanation: From the left cell, moving up, down, or left exits immediately, giving three paths. Moving right reaches the other cell, from which up, down, or right exits on the second move. The total is 3+3=6.
Constraints:
1 <= m, n <= 500 <= maxMove <= 500 <= startRow < m0 <= startColumn < n