#t417. 方格取数
方格取数
Picking Numbers on a Grid
Problem Description
There is an grid . Some cells contain a positive integer, while others contain . As shown in the figure below (see sample):

A person starts from point at the top-left corner and can only move down or right, until reaching point at the bottom-right corner. Along the way, he can pick up the number in a cell (the cell then becomes ). This person walks from to twice. Find such paths so that the sum of the numbers picked is maximized.
Input Format
The first line of input is an integer (indicating the grid). Each of the following lines contains three integers: the first two indicate a position, and the third is the number placed at that position. A single line of 0 indicates the end of input.
Output Format
Output a single integer: the maximum sum obtained along the paths.
Sample Input 1
8
2 3 13
2 6 6
3 5 7
4 4 14
5 2 21
5 6 4
6 3 15
7 2 14
0 0 0
Sample Output 1
67
Constraints
.