Maximum Sum of K Non-Overlapping Submatrices

No attempts yetTime limit2sMemory limit32 MB

Problem

You are given an N×MN \times M matrix of integers. Choose exactly KK pairwise non-overlapping submatrices so that the total sum of all elements contained in the chosen submatrices is as large as possible.

A submatrix is a rectangular block cut from the matrix, formed by consecutive rows and consecutive columns, and its size is at least 1×11 \times 1. Two submatrices overlap if they share at least one common cell. Touching only along an edge or at a corner does not count as overlapping.

Input

The first line contains three space-separated integers NN, MM, and KK: the number of rows, the number of columns, and the number of submatrices you must choose. (1K31 \le K \le 3, KN300K \le N \le 300, KM300K \le M \le 300)

Each of the next NN lines contains MM space-separated integers. The jj-th integer on the ii-th line is the element aija_{ij} at row ii and column jj. (20000aij20000-20000 \le a_{ij} \le 20000)

Output

Print, on a single line, the maximum possible sum of all elements contained in the KK chosen submatrices.

Hint

You must choose exactly KK submatrices, and each submatrix is at least 1×11 \times 1. Even when every element is negative you still have to choose KK of them, so pick them to minimize the loss.