Mislav and Marko have devised a new game, creatively named Rotate. First, Mirko imagines a number sequence of length and divides it into sections, with each section containing numbers ( evenly divides ). The first section contains numbers in the first positions in the sequence, the second section the following positions, and so on.
Then, Marko asks Mislav to apply a number of operations on the sequence, with each operation being one of the following two types:
Rotate the numbers in each section to the left/right by positions
Rotate the whole sequence to the left/right by positions
Notice that an operation of type 2 can change the numbers belonging to each section. After applying all the operations, Mislav reveals the final sequence to Marko. Marko's task is finding Mislav's starting sequence. He has asked you for help.
输入格式
The first line of input contains three positive integers: ( ), the length of the sequence, ( ), the size of each section, and ( ), the number of operations.
Each of the following lines contains two integers: ( ), the operation type, and ( ), the number of positions to rotate by. A negative number represents rotation to the left, while a positive one represents rotation to the right.
The last line of input contains space-separated integers ( ) representing the final sequence (after applying all operations).
输出格式
The first and only line of output must contain the required starting sequence.
样例
样例输入 1
4 2 2
2 2
1 1
3 2 1 0
样例输出 1
0 1 2 3
样例输入 2
8 4 4
1 3
1 15
1 -5
2 -1
6 10 14 19 2 16 17 1
样例输出 2
6 10 14 1 2 16 17 19
样例输入 3
9 3 5
1 1
2 -8
2 9
1 1
2 -4
3 1 8 7 4 5 2 6 9
样例输出 3
5 3 6 9 7 1 8 2 4
数据范围与提示
SCORING
In test data worth at least of total points, will be at most . In test data worth at least of total points, will be at most .
Clarification of the first example
The starting sequence is . After the first operation, the sequence is , and after the second operation, it becomes . This corresponds to the final sequence.