Matrix Transformation#11763

Matrix Transformation

0.1 seconds
256 megabytes
Medium

You are given an integer matrix of size M \times N and an integer .

Perform transformations on the matrix according to the following rule:

1. A new matrix of size (M - 1) \times (N - 1) is created.

Each element of the new matrix B_{i, j} is set to the maximum of the four adjacent elements in the previous matrix (or the initial matrix for the first step):

B_{i, j} = \max(A_{i, j}, A_{i+1, j}, A_{i, j+1}, A_{i+1, j+1}),

where is the previous matrix and is the new matrix.

2. The process stops if either of the following occurs: - transformations have been performed, or - the matrix size is reduced to row and/or column.

After completing the transformations, print the resulting matrix obtained after transformations (or after the matrix is reduced to row and/or column).

Input

The first line contains three integers: - (2 \le M \le 100) — the number of rows in the initial matrix; - (2 \le N \le 100) — the number of columns in the initial matrix; - (1 \le K \le 100) — the number of transformations to perform.

Each of the next lines contains integers A_{i, j} (-1000 \le A_{i, j} \le 1000).

Output

Print the resulting matrix.

Examples

Example 1

Loading
Loading

Example 2

Loading
Loading