10202 - Problem 3   

Description

Given a square matrix of size N-by-N, compute its smallest row sum and smallest column sum. For example, if the matrix is
4 9 2
1 6 5
7 8 3
the smallest row sum is 12 (the sum of the second row), and the smallest column sum is 10 (the sum of the third column).

Input

The first line is an integer N (1<=N<=10) denoting the size of the matrix.
The next N lines contain the N*N elements of the matrix. The elements of the matrix are nonnegative integers.

Output

The results are shown in two lines. The first line is the smallest row sum and the second line is the smallest column sum. Each line is ended with a newline character '\n'.

Sample Input  Download

Sample Output  Download

Tags




Discuss