#K90572. Sum of Maximum Elements in Matrix Rows

    ID: 37782 Type: Default 1000ms 256MiB

Sum of Maximum Elements in Matrix Rows

Sum of Maximum Elements in Matrix Rows

This problem requires you to compute the sum of the maximum elements in each row of several square matrices. For each test case, you are given an integer N representing the size of the matrix, followed by N lines each containing N space-separated integers. Your task is to compute, for each matrix, the value:

\(\sum_{i=1}^{N} \max(\textbf{row}_i)\)

and output the result on a separate line for each test case.

inputFormat

The first line of input contains an integer T denoting the number of test cases. Each test case begins with an integer N on a new line, which represents the size of the square matrix. This is followed by N lines, each containing N space-separated integers.

Input is provided via standard input (stdin).

outputFormat

For each test case, print a single integer representing the sum of the maximum elements from each row of the matrix. Each output should appear on a new line.

Output is to be printed via standard output (stdout).

## sample
2
3
1 2 3
4 5 6
7 8 9
2
-1 -2
3 4
18

3

</p>