It's a well known fact that in some cultures the number brings bad luck.
Task
You are given a number consisting of digits. You are to compute how many numbers smaller than or equal to don't contain as a substring in their base representation. Since the answer can be quite large, you are to print it modulo .
In addition, you are to process queries of two possible types:
Query(radixL, radixR)
: you are to compute how many numbers smaller than or equal to don't contain as a substring in their base representation. Since the answer can be quite large, you are to print it modulo stands for the substring of starting from the -th digit and ending with the -th digit counting from left to rightUpdate(radix, newDigit)
: one of 's digits is replaced. In particular, digit numbered counting from left to right is changed to .
Input data
The first line of input contains two integers and - the number of digits of number and the number of queries that need to be processed.
The second line of input contains the number .
The next lines describe the queries that need to be processed. Each line starts with an integer - the type of query that needs to be processed.
If , then the line describes a and two integers and follow - the left and right ends of the substring that you need to consider as bounds for the query.
Otherwise , the line describes an Update and two integers and follow - the position of the digit that needs to be changed and the new value of the digit.
Output data
The first line of the output contains a single integer - how many numbers smaller than or equal to don't contain as a substring in their base representation. Since the answer can be quite large, you are to print it modulo .
Then, for each query of the first type, print the answer modulo on a separate line.
Constraints and clarifications
- If then
- If , then
# | Points | Restrictions |
---|---|---|
1 | 14 | |
2 | 14 | |
3 | 9 | , all queries will be of the first type |
4 | 27 | , all queries will be of the first type |
5 | 9 | |
6 | 27 | No further restrictions. |
Example
stdin
6 10
560484
2 6 4
2 1 4
2 5 6
2 6 1
2 3 6
1 3 6
1 1 3
1 6 6
1 2 6
2 1 7
stdout
528145
6228
452
2
63454
Explanation
There are non-negative integers smaller than or equal to not containing digits as a substring in their base representation. Note that this includes the number .
- is initially .
- After update
2 6 4
, becomes . - After update
2 1 4
, becomes . - After update
2 5 6
, becomes . - After update
2 6 1
, becomes . - After update
2 3 6
, becomes . - Query
1 3 6
asks us how many non-negative integers smaller than or equal to don't contain substring - there are such numbers. - Query
1 1 3
asks us how many non-negative integers smaller than or equal to not containing substring - there are such numbers. - Query
1 6 6
asks us how many non-negative integers smaller than or equal to not containing substring - there are such numbers: and . - Query
1 2 6
asks us how many non-negative integers smaller than or equal to not containing substring - there are such numbers. - After update
2 1 7
, becomes .