TREASURE
Miltos the dolphin found a treasure map and is trying his best to find the treasure. He wants you to help him decipher a sequence of integers , in order to find the coordinates where the treasure is located. The curious thing about this map is that it is magical, meaning each integer can change at any given moment. To help him, Miltos sends you commands, and you need to execute them appropriately. The commands are of two types:
- : Miltos informs you that the new value of the -th integer is .
- : Miltos asks you to display the value of with .
Input
The first line contains ,. The next line contains the integers , , , separated by spaces. The following lines are of the form or and are Milto's commands.
Output
The output file should have as many lines as there are commands of the form . Each line will contain the corresponding result. You should display all results mod .
Constraints
For 50% of the test cases
- Time limit: sec.
- Maximum available memory: MB.
Example of Input - Output
STDIN (treasure.in)
5 5
8 3 6 2 7
1 1 2
1 3 5
0 4 9
1 3 5
1 4 4
STDOUT (treasure.out)
14
31
45
9
Comments