Hide

Problem U
Just for Sidekicks

The ponies’ pets are playing with some gems they found. There are six types of gems, with values V1,V2,,V6, respectively.

They have laid out N gems in a row. The ith of these gems is of type Pi.

Now, with nothing better to do and no better way to hide a queries on an array problem, they make Q queries on the gems. In the ith query, either:

  • they replace the Kith gem with a gem of type Pi,

  • they revalue the Pith type of gem as having value Vi, or

  • they want to know the total value of the gems from the Lith one to the Rith one, inclusive.

Please help them answer the queries!

Input

The first line of input contains two integers, N (1N200000) and Q (1Q200000), the number of gems, and the number of queries, respectively.

The second line of input contains six integers, V1,V2,,V6 (1Vi109), the values of the types of gems.

The third line of input contains a string of N characters. In particular, the ith of these characters contains Pi (1Pi6), the type of the ith gem.

The next Q lines contain the queries. In particular, the ith of these lines begins with a single integer:

  • If this integer is 1, two integers Ki (1KiN) and Pi (1Pi6) follow, indicating that they replace the Kith gem with a gem of type Pi. It is guaranteed that Pi is different from the type of the Kith gem.

  • If this integer is 2, two integers Pi (1Pi6) and Vi (1Vi109) follow, indicating that they revalue the Pith type of gem as having value Vi. It is guaranteed that Vi is different from the value of the Pith type of gem.

  • If this integer is 3, two integers Li and Ri (1LiRiN) follow, indicating that they want to know the total value of the gems from the Lith one to the Rith one, inclusive.

It is guaranteed that there is at least one query of type 3.

Output

For each query of type 3, output a single integer on a line by itself, the total value of gems from the Lith one to the Rith one, inclusive.

Sample Input 1 Sample Output 1
8 5
10 30 25 420 39 69
55513642
3 2 6
1 1 6
2 6 3286
3 2 6
3 1 8
182
3399
7135
Hide

Please log in to submit a solution to this problem

Log in