Sucrose has been entrusted with a row of mysterious potions retrieved from Fatui hideouts, where the
th potion has a magic value of
. She will perform
operations, each of type
, which can be one of the following:
She adds a special solution to the potion at position
, increasing its magic value by
. Note that
can be nonpositive.
She uses her Anemo powers to multiply the magic values of all potions by a factor of
. Note that
can also be nonpositive.
She asks you for the current magic value of the potion at position
.
All magic values should be returned modulo , as it can be mathemagically proven to have the same effect.
Constraints
Subtask 1 [5%]
Subtask 2 [35%]
There are no type operations. Formally,
.
Subtask 3 [60%]
No additional constraints.
Input Specification
The first line of input contains space separated integers,
and
, the number of potions and the number of operations.
The second line of input contains space separated integers,
, the initial magic value of each potion.
The next lines of input contains
for type
operations,
for type
operations, and
for type
operations.
Output Specification
For each type operation, output
integer on its own line, the magic value of the queried potion, modulo
.
Sample Input 1
5 3
1 2 3 4 2
1 3 5
2 4
3 3
Sample Output 1
32
Explanation for Sample Output 1
The first operation increases the 3rd potion's magic value by .
The second operation multiplies all potions' magic values by .
The potions' magic values after these operations are: .
The third operation outputs the 3rd potion's magic value, .
Sample Input 2
4 4
1 1 1 1
2 -3
3 1
2 0
3 2
Sample Output 2
999999997
0
Explanation for Sample Output 2
The first operation multiplies all potions' magic values by .
Note that mod
.
Comments