You & Spiral

Author: Abu Rayhan Ahmad

Problem Setter: . Hasan Ali, 24th Intake, Dept. of CSE

Bangladesh University of Business and Technology (BUBT)

It’s a game. Have two players you and your enemy. You have a matrix of r*c (row and column). In each step both you and your enemy must be collect all point from entire row/column which are not collected by opponent. The collection must start from row and then consecutively column and row. First your enemy starts and he/she start from bottom right corner. Let’s simulate first.


First Step:


Second Step:


Third Step:


Forth Step:


And all collected. And enemies point is 36.
Now, your task is to find out your enemies total point.

Input Format

First line of input consist two number r(0<r<=1000)  and c(0<n<=1000)  denoting the number of row and column of the matrix (for the example above row is 5 and column is 4). Next there will given a r*c matrix all values are between -10000 to 10000.

Output Format

Your task is to find the output.

Samples

Input
5 4 6 5 3 -6 4 6 2 1 2 -4 -1 3 4 -3 1 6 2 4 5 8
Output
36
Limits
Language Time Memory
GNU C 11 1s 512MB
GNU C++ 14 1s 512MB
GNU C++ 11 1s 512MB
Statistics
Login To Submit