Matrix Transformation#537

Matrix Transformation

0.1 seconds
256 megabytes
Easy (≈1000)

You are given an integer matrix of size x and an integer .

Perform transformations on the matrix according to the following rule:

1. A new matrix of size ( – ) x ( – ) is created.

An element of the new matrix [, ] is determined as the maximum among four neighboring elements of the matrix obtained in the previous step (or the original matrix for the first step):

B[i, j] = (A[i, j], A[i+1, j], A[i, j+1], A[i+1, j+1]),

where is the original matrix, is the new matrix.

2. The process terminates if:

• matrix transformations have been performed, or

• the size of the matrix has reduced to row and/or column.

After completing the transformations, output the elements of the matrix obtained after performing transformations (or reducing the matrix to row and/or column).

Input

The first line contains three numbers:

- ( ≤ ≤ ) – the number of rows of the initial matrix;

- ( ≤ ≤ ) – the number of columns of the initial matrix;

- ( ≤ ≤ ) – the number of transformations to perform.

In the next lines, integers [i, j] ( ≤ A[i, j] ≤ ) are written.

Output

Output the resulting matrix.

Examples

Example 1

Loading
Loading

Example 2

Loading
Loading