There is a pile of crabs standing on one top of another.
There are total crabs numbered to . The crab numbered is at the bottom of the pile. Crab numbered is on top of crab and so on. The crab numbered is at the top of the pile.
Each crab has an initial health value represented with an integer number.
You have to observe events.
For each event, a crab numbered will start climbing from his position to the top of the pile. Every crab he will cross on his way, he will decrease their health value by . If one’s health is equal to 0, the crab is dead and his value will not get decreased further. If the crab numbered is already on the top of the pile, he will not move.
If the crab numbered is already dead, he will not climb the pile. You have to report the crab is dead.
After observing all the events, you’ve to print the health value of each crab.
The first line on input consists of two integers and represents the number of crabs and the number of events respectively.
Each of the next lines consists of an integer value represents the health of crab for each from to .
Each of the next lines consists of an integer represents the crab that will climb up the pile.
For each of the events, if the crab numbered is already dead, print in separate lines. Otherwise, do not print anything.
After observing all the events, print a single line with integers for each from to seperated by space. represent the health of crab after all the events.
Input | Output |
---|---|
4 3 2 3 1 4 2 3 1 | Dead 2 2 0 2 |
After the first event, the health of crab 1, 2, 3, and 4 is equal to 2, 3, 0, 3 respectively. In the second event, we can see crab 3 is already dead. So, it won’t move. After the third event, the health of crabs 1, 2, 3, and 4 is equal to 2, 2, 0, 2 respectively. |
Input | Output |
---|---|
10 16 19 5 26 71 16 2 22 8 85 24 8 1 2 1 4 4 9 9 9 5 8 2 6 10 6 9 | Dead Dead Dead 13 0 24 65 10 0 18 1 78 17 |