#P7572. 20
20
Description
For every , you are given such that:
- Commutativity: .
- Associativity: .
- Identity element: .
Define a function such that:
- .
- When , .
In particular, .
Define the function as:
Given and , for all , compute the values of $g\left(\left\lfloor \frac{m}{i} \right\rfloor, k, r\right)$ for all . Take all answers modulo .
Input Format
The first line contains two integers and .
Then follow lines, each with integers. The -th integer on the -th line is .
Output Format
Output lines.
The -th line contains four non-negative integers. The -th integer is $g\left(\left\lfloor \frac{m}{i} \right\rfloor, k, r\right)$.
10 0
0 1 2 3
1 2 3 0
2 3 0 1
3 0 1 2
2 2 3 3
2 1 1 1
1 0 1 1
100 100
0 1 2 3
1 0 3 2
2 3 0 1
3 2 1 0
457599333 476580683 403589597 762762658
361221912 612412943 661908092 483645330
242804711 682542199 535167020 465246643
913280460 516845083 917292729 390364642
39265044 919790719 181416471 421087779
530140662 31014314 181416471 226287885
982924733 31014314 851084249 226287885
982924733 938693280 851084249 226287885
982924733 938693280 851084249 435036575
982924733 938693280 851084249 138976409
Hint
This problem does not use bundled tests, and the testdata has a slight difficulty gradient.
For of the testdata, .
For of the testdata, , .
Translated by ChatGPT 5
京公网安备 11011102002149号