Олимпиадный тренинг

Задача 38471. Hyper minimum


You have a 4-dimensional array X, each index of which can take values ​​from 1 to N. You must construct a new 4-dimensional array Y , whose elements must take the following values: Y [i1, i2, i3, i4] = min(X[j1, j2, j3, j4]), where 1 ≤ ik ≤ N .minus; M + 1, ik ≤ jk ≤ ik + M − 1 and M -  given number.

Input
The first line of the input file specifies N and M (1 ≤ M ≤ N). The remaining lines of the file contain the elements of the array X. The number of elements will not exceed 1500000 and they themselves will be integers not exceeding 109 in absolute value. They are in such order that you can read them using pseudocode:

for i = 1 to N:
for j = 1 to N:
for k = 1 to N:
for l = 1 to N:
read X[i, j, k, l]

Imprint
Output the required array Y in the same format as the array X was given.
 
Examples
# Input Output
1 1 1
1
1
2 3 2
3 1 4 -4 0 4 0 0 -3 0 -2 -5 5 3 5 -4 4 -3 -5 -4 -4 5 -1 0 -3 -2 -1 2 -5 -5 -1 1 1 - 4 3 5 3 -3 -3 3 0 1 4 -1 -2 3 -2 5 4 -1 -5 3 -4 0 -3 -1 3 -1 4 4 -1 -5 -3 4 -4 5 1 5 -4 3 2 2 -2 -2 4 2 -4 -3 1 3 1
-5 -5 -4 -3 -5 -5 -4 -5 -5 -5 -5 -5 -4 -5 -4 -5