10192 - Train   

Description

tTrainThere is a train with 10 carriages. The carriages have different numbers of passengers. For example, the numbers of passengers they have could be 5 8 23 10 30 20 15 10 2 2.

Passengers can get on, get off, move forward and move backward the carriages. The operations are presented in a format as follows:

I 0 0 0 5 4 3 4 0 0 1
O 0 1 1 0 0 2 3 0 0 0
F 0 0 0 0 2 0 0 0 0 0
B 0 1 0 0 0 0 0 0 0 0
O 2 0 0 0 0 0 0 0 0 0
I 0 0 0 0 5 0 0 0 0 0

where 'I' stands for getting on, 'O' stands for getting off, 'F' stands for moving forward, and 'B' stands for moving backward. The numbers represent the numbers of passengers doing the action on the corresponding carriages.

For example, the getting on operation "I 0 0 0 0 5 0 0 0 0 0" means that five passengers get on the 5th carriage, and likewise, the getting off operation "O 2 0 0 0 0 0 0 0 0 0" means that two passengers get off the 1st carriage. The moving forward operation "F 0 0 0 0 2 0 0 0 0 0" means that two passengers move from the 5th carriage to the 4th carriage, and likewise, the moving backward operation "B 0 1 0 0 0 0 0 0 0 0" means that a passenger moves from the 2nd carriage to the 3rd carriage.

Example:

Operation

Number of passenger in each carriage

 

5 8 23 10 30 20 15 10 2 2

I 0 0 0 5 4 3 4 0 0 1

5 8 23 15 34 23 19 10 2 3

O 0 1 1 0 0 2 3 0 0 0

5 7 22 15 34 21 16 10 2 3

F 0 0 0 0 2 0 0 0 0 0

5 7 22 17 32 21 16 10 2 3

B 0 1 0 0 0 0 0 0 0 0

5 6 23 17 32 21 16 10 2 3

O 2 0 0 0 0 0 0 0 0 0

3 6 23 17 32 21 16 10 2 3

I 0 0 0 0 5 0 0 0 0 0

3 6 23 17 37 21 16 10 2 3

 

Note that none of the passengers will move forward from the 1st carriage, and likewise, none of the passengers will move backward from the 10th carriage. And the number of passengers that is going to get off the carriage will not exceed the number of passengers in that carriage.

Input

The first line contains ten positive integers indicating the initial numbers of passengers on the ten carriages.

The second line contains an integer N (1<=N<=100) denoting the number of operations.

The next N lines contain the N operations.

Output

Output the numbers of passengers from the 1st carriage to the 10th carriage. The numbers are separated by a space.

[Note]There is a space at the end of the output but no newline at the end.

Sample Input  Download

Sample Output  Download

Tags




Discuss