#t386. 摘花生

摘花生

Hello Kitty's Peanuts

Problem Description

Hello Kitty wants to pick some peanuts to give to her favorite Mickey Mouse. She comes to a rectangular peanut field with grid-like roads (as shown in the figure below), entering from the northwest corner and exiting from the southeast corner. At every road intersection in the field there grows a peanut plant with a number of peanuts on it; passing a peanut plant lets her pick all the peanuts on it. Hello Kitty can only walk east or south, never west or north. What is the maximum number of peanuts Hello Kitty can pick?

Input Format

The first line is an integer TT, the number of data groups in total (1≤T≤1001 \le T \le 100).

This is followed by TT data groups.

The first line of each data group contains two integers, the number of rows RR and the number of columns CC of peanut plants (1≤R,C≤1001 \le R, C \le 100).

The next RR lines of each data group describe the peanut plants in each row, from north to south. Each line contains CC integers, describing the number of peanuts MM on each plant in that row from west to east (0≤M≤10000 \le M \le 1000).

Output Format

For each input data group, output one line with the maximum number of peanuts Hello Kitty can pick.

2
2 2
1 1
3 4
2 3
2 3 4
1 6 5
8
16

Source

一本通在线评测