atcoder#ABC298D. [ABC298D] Writing a Numeral
[ABC298D] Writing a Numeral
Score : points
Problem Statement
We have a string . Initially, 1
.
Process queries in the following formats in order.
1 x
: Append a digit at the end of .2
: Delete the digit at the beginning of .3
: Print the number represented by in decimal, modulo .
Constraints
- For each query in the first format, .
- A query in the second format is given only if has a length of or greater.
- There is at least one query in the third format.
Input
The input is given from Standard Input in the following format:
Here, denotes the -th query, which is in one of the following formats:
Output
Print lines, where is the number of queries in the third format. The -th line should correspond to the -th query in the third format.
3
3
1 2
3
1
12
In the first query, is 1
, so you should print modulo , that is, .
In the second query, becomes 12
.
In the third query, is 12
, so you should print modulo , that is, .
3
1 5
2
3
5
11
1 9
1 9
1 8
1 2
1 4
1 4
1 3
1 5
1 3
2
3
0
Be sure to print numbers modulo .