#Lutece1310. Dynamic Dynamic Programming

Dynamic Dynamic Programming

Migrated from Lutece 1310 Dynamic Dynamic Programming

All parts of this problem, including description, images, samples, data and checker, might be broken. If you find bugs in this problem, please contact the admins.

Description

There is a common formula of dynamic programming:

title

Now let's make it more dynamic. You will be given the cjc_j for 1jn1\leq j\leq n initially, then there are two types of query:

  1. Change cjc_j to vv.

  2. Return the value of dpi,jdp_{i,j}.

It is guaranteed that 1jn1\leq j\leq n for all jj above.

Input

the first line contains two integers nn and mm: the length of the array cc and the number of queries.

There are nn integers in next line. The jthj^{th} integer indicates cjc_j.

Then mm lines is following, each with a query. There are two types of query:

1 j v: Change cjc_j to vv.

2 i j: Return the value of dpi,jdp_{i,j}.

1n,m1051\leq n, m\leq 10^5

0cj,v1090\leq c_j, v\leq 10^9

0i200\leq i\leq 20

1jn1\leq j \leq n

Output

For each query 2 i j, output the answer in one line. As the answer may be too large, output it modulo (109+7)(10^9+7) (i.e. if the answer is XX, you should output X % (109+7)X\ \%\ (10^9+7)).

Samples

3 4
1 2 3
2 1 2
2 2 3
1 1 2
2 2 3
3
10
13

Resources

The 14th UESTC Programming Contest Final