PHƯỚC HƯNG OJ · THỬ THÁCH THUẬT TOÁN

#FT0000180. Xâu con của xâu đã sắp xếp (Substring of Sorted String)

HỌC THEO LỘ TRÌNH

Bài tập thuộc lộ trình

1 lộ trình

Xâu con của xâu đã sắp xếp (Substring of Sorted String)

Substring of Sorted String

Source: AtCoder

Version: Phuoc Hung OJ Extended

Problem Statement

You are given a lowercase string SS of length NN. Operation 1 x c replaces character xx by cc. For 2 l r, form TT by sorting the entire current string SS in nondecreasing alphabetical order. Decide whether the exact contiguous substring Sl…SrS_l\ldots S_r occurs as a contiguous substring somewhere in TT. Being nondecreasing by itself is insufficient if the interval omits occurrences of letters strictly between its endpoint letters.

Input

The first line contains NN; the second line contains exactly NN lowercase letters forming SS; the third line contains QQ. Each of the last QQ lines is 1 x c or 2 l r.

Output

For each type-2 query, print exactly Yes if the chosen substring occurs contiguously in the sorted string TT, and No otherwise.

Subtasks

  • Subtask 1 (20 points): 1≤N≤301\le N\le 30; 1≤Q≤1001\le Q\le 100; SS has length exactly NN with lowercase English letters; each command is 1 x c, 1≤x≤N1\le x\le N and c lowercase, or 2 l r, 1≤l≤r≤N1\le l\le r\le N; at least one type-2 query in the PHOJ test set.
  • Subtask 2 (30 points): 1≤N≤30001\le N\le 3000; 1≤Q≤50001\le Q\le 5000; SS has length exactly NN with lowercase English letters; each command is 1 x c, 1≤x≤N1\le x\le N and c lowercase, or 2 l r, 1≤l≤r≤N1\le l\le r\le N; at least one type-2 query in the PHOJ test set.
  • Subtask 3 (50 points): 1≤N≤1000001\le N\le 100000; 1≤Q≤1000001\le Q\le 100000; SS has length exactly NN with lowercase English letters; each command is 1 x c, 1≤x≤N1\le x\le N and c lowercase, or 2 l r, 1≤l≤r≤N1\le l\le r\le N; at least one type-2 query in the PHOJ test set.

Examples

Example 1

Input

6
abcdcf
4
2 1 3
2 2 6
1 5 e
2 2 6

Output

Yes
No
Yes

Explanation

  1. 2 1 3: current sorted full string is abccdf; queried substring abc is present as a contiguous substring, so print Yes.
  2. 2 2 6: current sorted full string is abccdf; queried substring bcdcf is absent as a contiguous substring, so print No.
  3. 1 5 e: replace position 5: c → e; current string abcdef. No output.
  4. 2 2 6: current sorted full string is abcdef; queried substring bcdef is present as a contiguous substring, so print Yes.

Example 2

Input

3
abc
4
2 1 2
1 3 a
2 1 3
2 2 3

Output

Yes
No
No

Explanation

  1. 2 1 2: current sorted full string is abc; queried substring ab is present as a contiguous substring, so print Yes.
  2. 1 3 a: replace position 3: c → a; current string aba. No output.
  3. 2 1 3: current sorted full string is aab; queried substring aba is absent as a contiguous substring, so print No.
  4. 2 2 3: current sorted full string is aab; queried substring ba is absent as a contiguous substring, so print No.