#able. [abl_e]Replace Digits
[abl_e]Replace Digits
Problem Statement
You have a string of length . Initially, all characters in are 1
s.
You will perform queries times. In the -th query, you are given two integers and a character (which is a digit). Then, you must replace all characters from the -th to the -th (inclusive) with .
After each query, read the string as a decimal integer, and print its value modulo .
Constraints
- All values in input are integers.
Input
Input is given from Standard Input in the following format:
Output
Print lines. In the -th line print the value of after the -th query, modulo .
Sample Input 1
8 5
3 6 2
1 4 7
3 8 3
2 2 2
4 5 1
Sample Output 1
11222211
77772211
77333333
72333333
72311333
Sample Input 2
200000 1
123 456 7
Sample Output 2
641437905
Don't forget to take the modulo.