The scenario: You are a police officer and there are some bad guys hiding behind the blocks.
Given a map represented as a two-dimensional array, the bad guys are hiding at the top row of the map. From the second row to the bottom, there are several blocks. You are at the bottom row of the map. You have to use your gun to destroy the blocks in front of you so that you can defeat the bad guys.
Every bad guy or block has a vitality level. When you fire at a block, the vitality level of it is decreased by 1; if the vitality level of a block becomes 0, it is destroyed. Similarly, when you fire at a bad guy, his vitality level is decreased by 1. If his vitality level is 0, he is defeated.
The following image shows the situation at certain moment.
.png)
The first line contains two numbers I and J, which denote the size of the place (I for rows and J for columns, 3 <= I, J <= 5).
The next line contains J numbers, which indicate the vitality levels of the bad guys at the corresponding columns. If the number is 0, it means that at that column there is no bad guy.
The following I-1 lines indicate the existence of blocks from row 2 to row I. Each line contains J numbers corresponding to the J columns. If the number is larger than 0, it means that there is a block at that column. Note that there is no block at row I, which means that all the J numbers for row I are 0.
The value of vitality level is between 1 and 9.
The final line gives a sequence of instructions telling that, at which column you should fire. The end of the instructions is marked as 'e'.
For example, if the instructions are "1 2 1 e", you should fire at the first column, then the second column, and then the first column again. The length of sequence is less than 10.
Show the final configuration of the map after the instructions are done, using the same form as the input.
That means every integer in the map is printed by "%2d". Remember to print a newline character '\n' at the end of each row.