Given a n×nn \times nn×n grid, with each point having a value ai,ja_ {i, j}ai,j(coordinate is from 1∼n1 \sim n1∼n).
Now you need to select mmm points, one of which is considered as a good point [i,j][i, j][i,j] if it satisfy one of the conditions. Otherwise, it's a bad point.
∙\bullet∙ i = 1\ \ i \ = \ 1 i = 1
∙\bullet∙ 1<i≤n,1<j<n1 < i \le n , 1< j < n1<i≤n,1<j<n and [i−1, j−1]\ \ [i -1,\ j - 1] [i−1, j−1] and [i−1, j+1][i -1, \ j + 1][i−1, j+1] are both selected
A selection is legal if and only if the number of bad points is less than or equal to kkk.
For m=1∼n2m=1 \sim n^2m=1∼n2, print the maximum value of the sum of all the points selected.
If there is no solution, output −1-1−1.