


In the example below, if we follow the path shown in the figure, then the minimum initial hp required will be 3.

The first line of the input contains ‘T,’ denoting the number of test cases. The 'T' test cases follow.
The first line of each test case contains two integers, ‘N’ and ‘M’, denoting the number of rows and columns of the board.
Next ‘N’ lines contain 'M' space-separated integers denoting the elements of the array 'board'.
For each test case, print an integer denoting the minimum initial hp required to reach the bottom-right corner of the board.
The output of each test case is printed in a separate line.
You do not need to print anything. It has already been taken care of. Just implement the given function.
1 <= T <= 5
1 <= N, M <= 1000
-3000 <= board[i][j] <= 3000
Where 'board[i][j]' represent the value of board at 'jth' column of 'ith' row.
Time Limit: 1 second
The main idea is to use recursion to reduce the big problem into several smaller subproblems.
We can see that we were solving the same subproblems multiple times. Thus, this problem was exhibiting overlapping subproblems. This means, in this approach, we need to eliminate the need to solve the same subproblems repeatedly. Thus, the idea is to use Memoization.
The steps are as follows: