#graph804. k 取方格数

k 取方格数

Grid Number Picking (k Paths)

Problem Description

You are given an n×nn \times n matrix where each cell holds a non-negative integer Ai,jA_{i, j}. Starting from (1,1)(1, 1) you may move only right or down to reach (n,n)(n, n); upon reaching a cell you take its number and that cell's value becomes 00. You repeat this walk kk times. For each k=1,2,…,nk = 1, 2, \dots, n, find the maximum possible sum of the numbers taken over kk walks.

Input Format

The first line contains one integer n (1≤n≤50)n\ (1 \le n \le 50).

The next nn lines each contain nn integers, the values Ai,j (1≤Ai,j≤1000)A_{i, j}\ (1 \le A_{i, j} \le 1000) of the matrix cells.

Output Format

Output nn lines, the answer for k=1,2,…,nk = 1, 2, \dots, n in order.

Sample Input

3
1 2 3
0 2 1
1 4 2

Sample Output

11
15
16