As a famous person with universal love, changing girlfriend too often makes me harassment because I can't keep their name in mind timely. To remember who is my lover now, I buy a magic password-box from a wizard.
As a faithful atheist, I do not believe that it is caused by magic power. By doing a deep research, I find that all "magic" factors are just because a small software inside the box. Because the software only uses some simple data structure, it has a dissatisfied complexity.
Now I shortly introduce the principle of the software.
We will support a string with dynamic length and three kinds of operations on it. You can assume that we will always have an initial string.
*1. You will receive a short string, and you should connect it after the original string to make the new string.
*2. You will receive an integer len, and you should answer the query: for each index i (1 <= i <= LEN(nowString)), we will get a sub-string from i to i + len - 1 (if i + len - 1 > LEN(nowString), you should make the suffix from index i as its sub-string). You should output the index i whose sub-string has minimum lexicographic.
*3. You will receive an integer len. You should delete the suffix whose length is len from the string now and get a new string.
As a former ACMer, I want to make a new production with better execution speed. But I am not good at data structure, so I need your help.