BETA

Submissions: 836 Accuracy: 39.35%

Sum of diagonals

Given a 2-D square matrix, find sum of elements in Principal and Secondary diagonals. For example, consider the following 4 X 4 input matrix.

```A00 A01 A02 A03
A10 A11 A12 A13
A20 A21 A22 A23
A30 A31 A32 A33```

The primary diagonal is formed by the elements A00, A11, A22, A33. And the secondary diagonal is formed by the elements A03, A12, A21, A30.

Input:
The first line consists of an integer T i.e number of test cases. The first line of each test case consists of an integer N.The next line consists of N*N spaced integers.

Output:
Print the sum of primary diagonal elements and the secondary diagonal elements with a space in between.

Constraints:
1<=T<=100
1<=N,a[i][j]<=1000

Example:
Input:

2
4
1 2 3 4 4 3 2 1 7 8 9 6 6 5 4 3
3
1 1 1 1 1 1 1 1 1

Output:
16 20
3 3

** For More Input/Output Examples Use 'Expected Output' option **

Contributor: Saksham Ashtputre

It is recommended to 'Compile & Test' your code before clicking 'Submit'!

Compilation/Execution Result: