This page is still under construction.

Parts of this page are still being built. What you see may change.

Interesting Permutations

Time limit5sMemory limit512 MB

Summary
Count permutations of 1..n whose first i elements are pairwise coprime, for every i, modulo m, stopping at the first impossible i.
Level

Medium7 of 10

Topics
Dynamic programming, Number theory, Combinatorics, Bit manipulation
Solved
No attempts yet

Problem

Vasya studies permutations of length nn: sequences of nn integers such that every integer from 11 to nn occurs in the sequence exactly once. Vasya says a permutation is kk-interesting if its first kk elements are pairwise coprime. By this definition, if a permutation is ii-interesting, it is also (i−1)(i - 1)-interesting.

Now Vasya wants to find the number of ii-interesting permutations for all ii from 11 to nn. If there is no ii-interesting permutation for a given ii, Vasya won't bother calculating for larger values of ii. For example, as numbers 22 and 44 are not coprime, there is no 55-interesting permutation of length 55.

Vasya does not like huge integers, so he calculates the number of permutations modulo a given integer mm. Help him do it.

Input

The first line contains two integers nn and mm (1≤n≤1001 \le n \le 100, 1≤m≤1091 \le m \le 10^9).

Output

Print kk lines, where kk is the maximum number such that there is at least one kk-interesting permutation of length nn. On the ii-th line, print the remainder modulo mm of the number of ii-interesting permutations of length nn.

Examples2

  1. Example 1

    Input
    5 239
    
    Expected output
    120
    108
    84
    48
    
  2. Example 2

    Input
    4 8
    
    Expected output
    0
    4
    4