#1103
Unrated
ROTIRAJ
시간 제한
1s
메모리 제한
32MB
제출
0
정답
0
맞힌 사람
0
정답 비율
0.0%

문제

Author: Matija Milišić

Mislav and Marko have devised a new game, creatively named Rotate. First, Mirko imagines a number sequence of length N and divides it into sections, with each section containing K numbers (K evenly divides N). The first section contains numbers in the first K positions in the sequence, the second section the following K 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: 1. Rotate the numbers in each section to the left/right by X positions 2. Rotate the whole sequence to the left/right by X 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: N (1 ≤ N ≤ 100 000), the length of the sequence, K (1 ≤ K ≤ 100 000), the size of each section, and Q (1 ≤ Q ≤ 100 000), the number of operations. Each of the following Q lines contains two integers: A (1 ≤ A ≤ 2), the operation type, and X (-100 000 ≤ X ≤ 100 000), 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 N space-separated integers Zi (0 ≤ Zi ≤ 100 000) 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
코드 제출

코드를 제출하려면 로그인이 필요합니다.

로그인
내 제출
제출 내역이 없습니다.
맞은 사람
아직 맞은 사람이 없습니다.
난이도 투표
Unrated0명 투표
로그인 후 AC 받으면 투표할 수 있습니다.
전체 제출
제출 내역이 없습니다.