TLE '17 Contest 4 P5 - Pascal's Tree
View as PDF
Fax McClad, Croneria's most decorative bounty hunter, has recently been fascinated with Pascal's triangle. He is in charge of decorating the Cronerian Christmas tree this year, so he does not want to miss an opportunity to reference Pascal's triangle in his design.
He decides to print the first  rows of Pascal's triangle on ornaments to hang on the tree. Since these numbers can get rather large, he will put the values modulo 
.
Unfortunately, Fax doesn't know what the values of the  row of the triangle are, modulo 
. Could you please help him? As a refresher, the 
 value (from 
 to 
) of the 
 row of Pascal's triangle is 
.
Constraints
| Subtask | Points | Additional Constraints | 
|---|---|---|
| 1 | 5 | |
| 2 | 10 | |
| 3 | 20 | |
| 4 | 20 | |
| 5 | 45 | None | 
Note: It may be helpful to know that  is prime.
Input Specification
The first line will contain  integers, 
 and 
.
Output Specification
Output  lines. The 
 line should contain a single integer, the value of 
.
Sample Input
4 6
Sample Output
1
4
0
4
1
Explanation for Sample Output
The  line of Pascal's triangle is 
. We calculate each element 
 to get 
.
Comments
This comment is hidden due to too much negative feedback. Show it anyway.