#P5734. 【深基6.例6】文字处理软件

【深基6.例6】文字处理软件

Description

You need to develop a word processing software. At the beginning, input a string as the initial document. You may assume that the start of the document is the 00-th character. The following operations must be supported:

  • 1 str: Append insertion. Insert the string str\texttt{str} at the end of the document, and output the document string.
  • 2 a b: Extract part of the document. Keep only bb characters starting from the aa-th character of the document, and output the document string.
  • 3 a str: Insert a segment. Insert the string str\texttt{str} before the aa-th character in the document, and output the document string.
  • 4 str: Find a substring. Output the earliest position of the string str\texttt{str} in the document; if it cannot be found, output 1-1.

To simplify the problem, the initial document and str\texttt{str} in each operation contain no spaces or newlines. There will be at most qq operations.

Input Format

The first line contains a positive integer qq, representing the number of operations.

The second line contains a string str\texttt{str}, representing the initial string.

Starting from the third line, the next qq lines each describe an operation, as shown in the problem description.

Output Format

Output a total of qq lines.

For each operation 1,2,31,2,3, output a string as required.

For operation 44, output an integer as required.

4
ILove
1 Luogu
2 5 5
3 3 guGugu
4 gu
ILoveLuogu
Luogu
LuoguGugugu
3

Hint

Constraints: 1q1001 \leq q \le 100, and the length of the initial string is 100\leq 100.

Translated by ChatGPT 5