String Palindrome Queries

Maintain a lowercase string under block moves, reversals, and single-character insertions, answering after each change whether a given substring reads the same forwards and backwards.

Hard10StringString matchingImplementationNo attempts yetTime limit2sMemory limit256 MB

Problem

You are given a string S=s1s2snS = s_1 s_2 \dots s_n of length nn. For xyx \le y, Sx,yS_{x,y} is the substring sxsys_x \dots s_y; for x>yx > y, Sx,yS_{x,y} is the empty string.

Process mm queries in the order they are given. There are two kinds.

Question query. You are given integers ii and jj. Decide whether the substring Si,jS_{i,j} is a palindrome.

Modification query. One of the following three.

  1. You are given integers ii, jj, kk. Cut SS into three parts S1,i1S_{1,i-1}, Si,jS_{i,j}, Sj+1,nS_{j+1,n}, any of which can be empty. Concatenate the first part with the last one into T=S1,i1Sj+1,nT = S_{1,i-1} S_{j+1,n}, whose length is n=n(ji+1)n' = n - (j - i + 1). Insert the middle part after the kk-th character of TT, forming S=T1,kSi,jTk+1,nS' = T_{1,k} S_{i,j} T_{k+1,n'}, and set SS to SS'.
  2. You are given integers ii and jj. Reverse the substring Si,jS_{i,j}.
  3. You are given an integer ii and a character cc. Insert cc right before position ii, that is, set S=S1,i1cSi,nS = S_{1,i-1} c S_{i,n}.

The third modification query makes the string one character longer, so nn means the length of the string just before the current query is processed.

Write a program that runs the queries above.

Input

The first line contains two space-separated integers nn and mm. (1n1051 \le n \le 10^5, 1m1051 \le m \le 10^5)

The second line contains the nn characters of the initial string.

Each of the next mm lines contains one query.

  • A question query has the form Q i j. (1ijn1 \le i \le j \le n)
  • Modification query 1 has the form M 1 i j k. (1ijn1 \le i \le j \le n, 0kn(ji+1)0 \le k \le n - (j - i + 1))
  • Modification query 2 has the form M 2 i j. (1ijn1 \le i \le j \le n)
  • Modification query 3 has the form M 3 i c, where cc is a single character. (1in+11 \le i \le n + 1)

On every line, nn is the length of the string just before that query is processed. You can assume that the string contains only lowercase letters of the English alphabet at all times. You may assume that the input is valid.

Output

For each question query, print the answer on its own line. Print YES if Si,jS_{i,j} is a palindrome and NO otherwise. Do not print the quotes.

Hint

In the first example the modification queries change the string like this.

  • Start: S=S = banana
  • After M 2 2 3: S=S = bnaana
  • After M 2 5 6: S=S = bnaaan
  • After M 3 7 b: S=S = bnaaanb
  • After M 1 1 2 4: S=S = aaanbnb

The last modification query cuts out the block bn and puts it back after the first four characters of the remaining string aaanb.