Jewel Magic#2056

Jewel Magic

5 seconds
64 megabytes
Very easy

I am a magician. I have a string of emeralds and pearls. I may insert new jewels into the string, or remove old ones. I may even reverse a consecutive part of the string. At any time, if you point to two jewels and ask me what is the length of the longest common prefix (LCP) of jewel strings starting from these two jewels, I can answer your question instantly. Can you do better than me?

Formally, you are given a string consisting of and . You have to perform four types of operations (in the following descriptions, denotes the current length of the string, and jewel positions are numbered to from left to right):

Input

There will be several test cases. The first line of each test case contains two integers and (1 \leq n, m \leq 200{,}000), where is the number of pearls initially and is the number of operations. The next line contains a string of length . Each of the next lines contains an operation. The input is terminated by end-of-file (). The size of the input file does not exceed  MB.

Output

For each type- operation, output the answer.

Examples

Example 1

Loading
Loading

Note

String after operation :

String after operation :

String after operation :