10985 - Column Sum and Row Sum   

Description

Given a M*N integer array, please output the smallest column-sum and row-sum.

Input

There are multiple test cases. Each case starts with two integers M and N in a line. Then a M*N integer array follows. Integers are separated by blank. All the numbers in the array are in the range [-107, 107]. Please see the sample input.

Case 1: 1 <= M, N <= 10
Case 2: 1 <= M, N <= 100
Case 3: 1 <= M, N <= 1000
Case 4: 1 <= M, N <= 100000, 1 <= M*N <= 1000000

 

Note : Don't use cin/cout for input/output.

Output

For each case, output the smallest column-sum and row-sum in a line, separated by a blank.

Sample Input  Download

Sample Output  Download

Tags




Discuss