시간 제한 메모리 제한 제출 정답 맞은 사람 정답 비율
1 초 128 MB 22 10 8 42.105%

문제

상근이와 정인이는 로테이트라는 새로운 게임을 창안했다. 먼저, 정인이는 길이가 N인 수열을 생각한다. 그 다음, 각 섹션에 K개의 수가 들어있도록 수열을 섹션으로 나눈다. (K는 N을 나눌 수 있는 수) 첫 번째 섹션에는 수열의 첫 K개 수가 포함되고, 두 번째 섹션에는 그 다음 K개 수가 포함된다. 나머지 섹션에도 이런식으로 수가 포함된다.

상근이와 정인이는 아래와 같은 두 가지 연산을 수열에 행할 수 있다.

1. 각 섹션을 왼쪽 또는 오른쪽으로 X만큼 회전(로테이트, Rotate)시킨다.

2. 수열 전체를 왼쪽 또는 오른쪽으로 X만큼 회전시킨다.

2번 연산은 수열 전체에 행하는 연산이기 때문에, 각 섹션에 들어있는 수를 바꿀 수도 있다. 정인이느 자기가 생각한 수열에 위의 연산을 수행한 다음에 상근이에게 최종 수열을 보여준다. 최종 수열과 정인이가 행한 연산이 순서대로 주어졌을 때, 처음 수열을 구하는 프로그램을 작성하시오.

입력

첫째 줄에 수열의 길이 N, 섹션의 크기 K, 정인이가 행한 연산의 수 Q가 주어진다. (1 ≤ N, K, Q ≤ 100,000)

다음 Q개 줄에는 정인이가 수열에 행한 연산이 순서대로 주어진다. 각 줄의 처음에는 어떤 연산인지를 나타내는 A (1 ≤ A ≤ 2)가 주어지며, 그 다음 수는 얼만큼 돌렸는지를 나타내는 X (-100,000 ≤ X ≤ 100,000)이다. 음수는 왼쪽 방향, 양수는 오른쪽 방향 회전이다.

마지막 줄에는 모든 연산을 수행하고 난 뒤의 최종 수열이 공백으로 구분되어서 주어진다.

출력

첫째 줄에 처음 정인이가 생각한 수열을 출력한다.

예제 입력 1

4 2 2
2 2
1 1
3 2 1 0

예제 출력 1

0 1 2 3

힌트

0 1 2 3 → 2 3 0 1 → 3 2 1 0

W3sicHJvYmxlbV9pZCI6IjUyMTUiLCJwcm9ibGVtX2xhbmciOiIwIiwidGl0bG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