## TLE '17 Contest 4 P5 - Pascal's Tree

View as PDF

Points: 15 (partial)
Time limit: 1.0s
Memory limit: 256M

Author:
Problem types
The Pascal's-triangle-influenced Christmas Tree.

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

15
210
320
420 is prime
545None

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 .