Under construction

Still being built. Things may change

Balanced bracket strings and queries

Time limit2sMemory limit1024 MB

Summary
Point updates change characters in a string of '(', ')', and '*', and range queries ask whether the stars in a substring can be filled to form a balanced bracket string.
Level

Medium6 of 10

Topics
String, Segment tree, Greedy
Solved
No attempts yet

Problem

This problem was adapted lightly from an online judge problem that inspired the author.

Balanced bracket string is a property of strings defined as follows.

  • The empty string ∅\varnothing is a balanced bracket string.
  • If A\mathbf{A} is a balanced bracket string, then (A)\mathtt{\color{#e74c3c}{(}} \mathbf{A} \mathtt{\color{#e74c3c}{)}}, which wraps A\mathbf{A} in brackets, is also a balanced bracket string.
  • If A\mathbf{A} and B\mathbf{B} are balanced bracket strings, then AB\mathbf{A} \mathbf{B}, their concatenation, is also a balanced bracket string.

You are given a string SS of length nn made only of '(', ')', and '*'. You must process qq queries of the following two types.

  • 1 i  ci \,\, c: Replace the ii-th character of SS with cc. cc is one of '(', ')', '*'. (1≤i≤n1 \le i \le n)
  • 2 l  rl \,\, r: Replace each '*' in the substring SlSl+1⋯Sr−1SrS_lS_{l+1}\cdots S_{r-1}S_r with '(', ')', or the empty string ∅\varnothing, choosing freely for each one. Then concatenate the remaining characters in their original order. Determine whether the result can be a balanced bracket string. (1≤l≤r≤n1 \le l \le r \le n)

Can you solve all queries fast enough?

Input

The first line contains the length nn of SS and the number of queries qq, separated by a space. (1≤n,q≤3⋅1051 \le n,q \le 3\cdot 10^5)

The second line contains the string SS of length nn. Every character of SS is one of '(', ')', '*'.

The next qq lines each contain one query, one of the two types described above.

Output

For each query of type 2, print 'Yes' if the substring can be turned into a balanced bracket string, and 'No' otherwise, each on its own line.

Examples1

  1. Example 1

    Input
    12 13
    (*)())()((*)
    2 1 12
    2 1 3
    2 1 6
    2 9 12
    2 9 11
    1 2 )
    2 1 3
    2 1 2
    2 1 6
    1 3 *
    2 1 12
    1 11 (
    2 1 12
    
    Expected output
    Yes
    Yes
    Yes
    Yes
    No
    No
    Yes
    No
    Yes
    No