#P10972. Controlled Territory Selection

    ID: 13021 Type: Default 1000ms 256MiB

Controlled Territory Selection

Controlled Territory Selection

Secret plans of Country A reveal that Country I is divided into an N×MN\times M grid of equal squares, each containing some oil resources. The United Nations only permits Country A to occupy exactly KK of these squares. However, to ensure that they can defend their territory effectively, the occupied region must be easy to control: for any two occupied squares, there must exist a path connecting them that uses no more than two directions (selected from left, right, up, and down; different pairs of squares may use different pairs of directions). Your task is to select KK squares to occupy. If multiple valid solutions exist, output any one of them.

inputFormat

The first line contains three integers NN, MM, and KK.

Each of the next NN lines contains MM integers representing the oil resources in the corresponding square.

outputFormat

Output NN lines, each containing MM numbers. Print 1 if the square is occupied and 0 otherwise. The output must contain exactly KK ones, and the occupied squares must satisfy the connectivity condition described in the problem statement.

sample

3 4 5
1 2 3 4
5 6 7 8
9 10 11 12
1 1 1 1

1 0 0 0 0 0 0 0

</p>