#P8936. [JRKSJ R7] 月下缭乱
[JRKSJ R7] 月下缭乱
Background

The light and lively music strengthens your determination to solve an easy problem.
(The background image comes from a Phigros song illustration. If there is any infringement, please inform the problem setter.)
Problem Description
You have a sequence of length , with all initial values equal to .
You have an operation sequence of length . The -th operation has three parameters , meaning that for all , set .
Let denote the sequence after applying operations through in order.
You need to answer how many pairs satisfy and .
Let be the number of with such that . You also need to output the values of and .
All answers should be output modulo .
Input Format
The first line contains two integers .
The next lines each contain three integers , describing the -th operation.
Output Format
Output three integers in one line, representing the answers modulo .
5 5
1 3 1
2 4 1
2 3 1
1 3 1
1 4 1
9 2 20
3 5
1 3 2
1 1 1
2 2 2
3 3 3
1 3 2
5 7 11
Hint
Idea: cyffff, Solution: Ntokisq / abruce, Code: cyffff, Data: cyffff.
Moonlit Dazzle - Tsukimi Shizuka vs. LUNARiUM (Insane14.8)
The input and output files for this problem are large, so please use appropriate I/O methods.
Sample Explanation
For sample , the final sequence is . It is easy to see that applying the operations in , , , , and can all make the same as the sequence after applying all operations. The answer is . The sequence is .
Constraints
This problem uses bundled testdata.
::cute-table | | | Special Constraints | | | :----------: | :----------: | :----------: | :----------: | | | | None | | | | | ^ | | | | | Guaranteed | | | | ^ | Guaranteed | | | | ^ | None | | | | | ^ | |
For of the testdata, , , .
Special Scoring
This problem enables subtask dependencies, as follows.
- For subtask , you only need to solve subtask correctly to get the score of subtask .
- For subtask , you need to solve all subtasks correctly to get the score of subtask .
Translated by ChatGPT 5