14095 - NTHU - Dormitory   

Description

The NTHU campus map is represented by an R × C table A, where Ai, j represents the number of residents (居住人數) in the dormitory located at (i, j). If Ai, j = -1, it means that the dormitory cannot accommodate residents.

We define K as the average dormitory satisfaction, which can be obtained through statistical analysis. Each day, every dormitory will transfer  (Integer division, round down) individuals to each of its four adjacent dormitories. Please output the numbers of residents in the dormitories after M days.

Note: Adjacency is defined in the four cardinal directions (up, down, left, and right). If there is no dormitory in that direction or if the adjacent dormitory cannot accommodate residents, no one will be transferred in that direction.

 

** No Recursion Is Required. :) **

Input

The first line consists of four positive integers, R, C, K, M.
Following that, there are R lines, each containing C integers Ai, j.

Constraints

  • Test Case 1: R = 1, M = 1
  • Test Cases 2 ~ 3: R = 1
  • Test Cases 4 ~ 6: satisfy no additional constraints.
  • For all test cases: 1 ≤ R, C ≤ 100, 4 ≤ K ≤ 100, 1 ≤ M ≤ 100, -1 ≤ Ai, j ≤ 100

Output

Output a total of R lines, each containing C integers Ai, j, representing the table A after M days.

Remember to print a ‘\n’ at the end of the output.

Do not include any spaces at the end of line.

Sample Input  Download

Sample Output  Download

Tags




Discuss