Under construction

Still being built. Things may change

Queries are not locks

Interview

Time limit2sMemory limit1024 MB

Summary
Given a string with single-character updates, answer range queries for the number of subsequences equal to ROCK, modulo 1000000007.
Level

Medium5 of 10

Topics
Segment tree, Dynamic programming, String
Solved
No attempts yet

Problem

Na-rak is a lock, a call from your parents is a lock, and 오락가락? is a lock?, but sadly a query is not a lock.

You are given a string S=s1s2…sNS=s_1 s_2 \ldots s_N of length NN made of uppercase English letters. Process QQ queries of the following kinds.

  • 11 idxidx cc: Change sidxs_{idx} to cc. (1≤idx≤N, c(1 \leq idx \leq N,\ c is an uppercase English letter))
  • 22 ll rr: Print the number of subsequences of slsl+1…srs_l s_{l+1} \ldots s_r that end with ROCK. Since the count can be very large, print it modulo 109+710^9+7. (1≤l≤r≤N)(1 \leq l \leq r \leq N)

Input

The first line contains the length NN of the string SS. (4≤N≤250000)(4 \leq N \leq 250000)

The second line contains the string SS, which consists only of uppercase English letters.

The third line contains the number of queries QQ. (1≤Q≤250000)(1 \leq Q \leq 250000)

The next QQ lines contain the queries. The last query given is a type 2 query.

Output

For each type 2 query, print the answer on its own line.

Hint

A subsequence of a string is a string obtained by deleting zero or more characters from it. For example, aan is a subsequence of hanyang.

Examples1

  1. Example 1

    Input
    6
    NAROCK
    3
    2 1 6
    1 3 C
    2 2 5
    
    Expected output
    4
    0