Maximum benefit path

Consider an r×cr \times c board, where every cell has a positive value. You are located at the top left cell, and you must go to the bottom right cell, never leaving the board. Every step must be made down or to the right, with one exception: you can make jj chess knight jumps (each, in any of the eight possible ways). Every time you pass by a cell you accumulate its value. Optimize the benefit.

Input

Input consists of several cases. Every case begins with rr, cc and jj, followed by rr rows with cc natural numbers between 1 and 10510^5. Assume that both rr and cc are between 3 and 100, and that jj is between 0 and 100.

Output

For every case, print the maximum possible benefit.

Problem information

Author: Unknown
Translator: Salvador Roura

Generation: 2026-01-25T10:14:20.037Z

© Jutge.org, 2006–2026.
https://jutge.org