atcoder#ABC256F. [ABC256F] Cumulative Cumulative Cumulative Sum
[ABC256F] Cumulative Cumulative Cumulative Sum
Score : points
Problem Statement
You are given , , and . Process queries, each of which is of one of the following two kinds:
1 x v
: update to .2 x
: let , , and . Print modulo .
Constraints
- All values in input are integers.
Input
Input is given from Standard Input in the following format, where denotes the -th query to be processed:
Each query is given in one of the following two formats:
Output
Print the answer to the queries, with newlines in between.
3 3
1 2 3
2 3
1 2 0
2 3
15
9
When the -st query is given, , so , , and ; thus, .
When the -rd query is given, , so , , and ; thus, .
2 1
998244353 998244353
2 1
0