시간 제한메모리 제한제출정답맞힌 사람정답 비율
10 초 256 MB318402442.857%

문제

그냥 단순히 문자열 조작 연산을 구현하는 문제이다. 문제 이름은 딱히 필요가 없어서 짓지 않았다.

입력

첫 줄에 테스트 케이스의 수 T가 주어진다. ( 1 ≤ T ≤ 100 )

각 테스트 케이스의 첫 줄엔 문자열 S가 주어진다. ( 1 ≤ |S| ≤ 1,000,000 )

이어서 한 줄 이상의 연산 내용이 주어진다. 문제에서 말하는 인덱스는 0부터 시작한다.

  • I R X : 문자열 S의 인덱스 X (0 ≤ X ≤ |S|) 에 문자열 R을 삽입한다. X=|S|인 경우엔 문자열 S의 뒤에 문자열 R을 이어붙인다. 예를 들어 문자열 S=abc일 때, I xy 1의 결과는 axybc, I xy 3의 결과는 abcxy, I xy 0의 결과는 xyabc가 된다.
  • P X Y : 문자열 S의 인덱스 X부터 Y까지의 문자를 출력한다. (0 ≤ X ≤ Y < |S|). 예를 들어 문자열 S=abc일 때, P 0 2의 출력은 abc, P 1 1의 출력은 b가 된다.
  • END : 테스트 케이스의 종료를 의미한다.
S와 R은 항상 알파벳 소문자로만 구성되어 있으며, 연산의 결과로 S의 길이가 100만을 넘어가는 경우는 없다. 또한, 출력되는 문자의 개수의 합은 모든 테스트 케이스에서 100만을 초과하지 않는다.
 
입력과 출력의 양이 방대하므로 빠른 입출력 함수 사용을 권장한다.

출력

P X Y 연산이 등장할 때마다 대응하는 부분 문자열을 출력한다.

예제 입력 1

1
acm
I ac 3
P 0 3
I x 3
I xxxx 6
I pc 6
P 0 11
END

예제 출력 1

acma
acmxacpcxxxx
W3sicHJvYmxlbV9pZCI6Ijk1NDgiLCJwcm9ibGVtX2xhbmciOiIwIiwidGl0bGUiOiJcdWJiMzRcdWM4MWMiLCJkZXNjcmlwdGlvbiI6IjxwPlx1YWRmOFx1YjBlNSBcdWIyZThcdWMyMWNcdWQ3ODggXHViYjM4XHVjNzkwXHVjNWY0IFx1Yzg3MFx1Yzc5MSBcdWM1ZjBcdWMwY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