CS and Sugar

Time Limit: 3000/1000 MS (Java/Others)

Memory Limit: 65768/32768 K (Java/Others)

Description

CS and Sugar find a new continent at the same time. Rare plants are all over this miraculous land, so they decided to take them home and sell it. But obviously, not all plants can be sold at a good price. Some plants are just usual weed. After some time of observation, they became self-taught botanists. CS and Sugar divided a rectangle area into n*m grids, and marked them with different values (maybe negative). They dig in turns to be fare, when all the plants in a grid are taken by the last person, and next person start to move on. The next person always chooses the one of the grids which are above and left to the last person, including the straight above or straight left. And even that, CS and Sugar still tried to compete with each other, and they always choose the available part with higher absolute value than last one no matter positive or negative. The first person can choose any grid to begin. Until someone is not able to make any move, they left. They are now debating who should dig first because they have already calculated how many advantages the first person can get.

Input

Multiple test cases (no more than 100), for each case:
The first line contains two integers n and m (0<n, m<=100), representing the rectangle area was divided into n*m parts.
Following n lines, each line contains m integers whose absolute value is no more than 100, representing the value in each part.

Output

For each case, output one integer, representing the maximum advantage the first person can get in total value.

Sample Input

1 5 -5 -4 -3 -2 -1 2 2 -7 -6 -6 5 3 2 -6 -5 -4 -4 2 4

Sample Output

1 4 3

Hint

lcy

Source

2011 Multi-University Training Contest 5 -

提交代码