Problem U
Just for Sidekicks
The ponies’ pets are playing with some gems they found.
There are six types of gems, with values
They have laid out
Now, with nothing better to do and no better way to hide a
queries on an array problem, they make
-
they replace the
gem with a gem of type , -
they revalue the
type of gem as having value , or -
they want to know the total value of the gems from the
one to the one, inclusive.
Please help them answer the queries!
Input
The first line of input contains two integers,
The second line of input contains six integers,
The third line of input contains a string of
The next
-
If this integer is
, two integers ( ) and ( ) follow, indicating that they replace the gem with a gem of type . It is guaranteed that is different from the type of the gem. -
If this integer is
, two integers ( ) and ( ) follow, indicating that they revalue the type of gem as having value . It is guaranteed that is different from the value of the type of gem. -
If this integer is
, two integers and ( ) follow, indicating that they want to know the total value of the gems from the one to the one, inclusive.
It is guaranteed that there is at least one query of type
Output
For each query of type
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 |