프로그램 명: coci_rotiraj
제한시간: 1 초

[요약]

K길이의 N/K개의 섹션으로 나누어진 길이 N의 수열이 있다. (N은 K로 나누어떨어진다)

N, K, 작업의 수 Q와 작업들, 작업의 결과 수열이 주어질 때 최초 수열은??
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 and only line of output must contain the required starting sequence.

입출력 예

입력

input

4 2 2
2 2
1 1
3 2 1 0

output

0 1 2 3

input

8 4 4
1 3
1 15
1 -5
2 -1
6 10 14 19 2 16 17 1

output

6 10 14 1 2 16 17 19

input

9 3 5
1 1
2 -8
2 9
1 1
2 -4
3 1 8 7 4 5 2 6 9

output

5 3 6 9 7 1 8 2 4


Clarification of the first example: The starting sequence is 0 1 2 3. After the first operations, the 
sequence is 2 3 0 1, and after the second operation, it becomes 3 2 1 0. Ths corresponds to the final 
sequence.
출처:coci/2012-2013/contest5 5번/6
요약:sujin

[질/답] [제출 현황] [푼 후(0)]
[ 채 점 ] [홈으로]  [뒤 로]