Ninja has been provided a matrix 'MAT' of size [tex]$N \times M$[/tex] where [tex]$M$[/tex] is the number of columns in the matrix, and [tex][tex]$N$[/tex][/tex] is the number of rows. The weight of a particular row is the sum of all elements in it. Ninja wants to find the maximum weight amongst all the rows. Your task is to help the ninja find the maximum weight amongst all the rows.

Example:

Input: [tex]N = 2, M = 3, \text{MAT} = [[1, 2, 3], [2, 0, 0]][/tex]
Output: 6

The weight of the first row is [tex]1 + 2 + 3 = 6[/tex].
The weight of the second row is [tex]2 + 0 + 0 = 2[/tex].
Hence, the answer will be a maximum of 2 and 6, which is 6.

Constraints:

[tex]\[
1 \leq T \leq 10 \\
1 \leq N \leq 10 \\
1 \leq M \leq 10
\][/tex]



Answer :

Sure, I can walk you through this problem step-by-step. The objective is to find the maximum weight among all rows in the matrix.

### Problem Breakdown:
1. Understand the Structure of the Matrix:
- We have a matrix `MAT` with `N` rows and `M` columns.
- Each row has `M` elements.

2. Definition of Row Weight:
- The weight of a row is the sum of all its elements.

3. Objective:
- We need to determine which row has the maximum weight and return that weight.

### Steps to Solve the Problem:

1. Initialize Variables:
- `max_weight` to keep track of the highest weight encountered while iterating through rows. Initially, this value can be set to zero.

2. Iterate Through Each Row:
- For each row, calculate the weight (sum of the elements in the row).
- If the weight of the current row is greater than `max_weight`, update `max_weight` with the current row's weight.

3. Output the Maximum Weight:
- At the end of the iteration, `max_weight` will hold the maximum weight of all rows.

### Example Walkthrough:

Given:
- [tex]\( N = 2 \)[/tex]
- [tex]\( M = 3 \)[/tex]
- [tex]\( \text{MAT} = \begin{bmatrix} 1 & 2 & 3 \\ 2 & 0 & 0 \end{bmatrix} \)[/tex]

Steps:

1. Initialize:
- `max_weight = 0`

2. First Row:
- Row: [tex]\([1, 2, 3]\)[/tex]
- Weight: [tex]\(1 + 2 + 3 = 6\)[/tex]
- Check if 6 is greater than `max_weight` (which is 0). Since it is, update `max_weight` to 6.

3. Second Row:
- Row: [tex]\([2, 0, 0]\)[/tex]
- Weight: [tex]\(2 + 0 + 0 = 2\)[/tex]
- Check if 2 is greater than `max_weight` (which is 6). Since it is not, keep `max_weight` as 6.

4. Final Result:
- The maximum weight found is 6.

Conclusion:
Thus, the maximum weight among all rows is [tex]\(\mathbf{6}\)[/tex].

### Summary:
By following the steps above, the final answer to the problem is 6. This means the row with the highest sum of its elements in the provided matrix results in the maximum weight of 6.