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

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

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.

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.

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.

提交代码