Holes and Balls

Time limit: 0.8s Memory limit: 256MB Input: Output:

There are 2N+12 \cdot N + 1 consecutive positions in a line, indexed from 00 to 2N2\cdot N from left to right.

  • There are NN balls, initially placed at positions 1,3,5,,2N11, 3, 5, \ldots, 2 \cdot N - 1.
  • There are N+1N + 1 holes, located at positions 0,2,4,,2N0, 2, 4, \ldots, 2 \cdot N.

You have to perform exactly NN moves, one for each ball. In a single move:

  • Choose any unused ball.
  • Push it either left or right.
  • The ball will continue moving in that direction until it reaches the first empty hole, where it will fall in and stop.

Note that there are N!2NN! \cdot 2^{N} distinct valid sequences of moves (each permutation of the balls, with each ball pushed either left or right), and at the end of every valid sequence exactly one hole will remain empty.

Your task is to compute, for each hole position ii from 00 to 2N2N, how many of these sequences leave hole ii empty at the end.

Since the answers may be large, calculate them modulo a given prime MM.

Input data

The first and only line of the input consists of two space-separated integers NN and MM - the number of balls and the prime modulus, respectively.

Output data

Output a single line containing N+1N + 1 space-separated integers - the number of different sequences of moves that leave hole ii (the hole at position 2i2\cdot i for each ii from 00 to NN) empty.

Constraints and clarifications

  • 1N1 000 0001 \le N \le 1 \ 000 \ 000.
  • 100 000 000M1 000 000 007100 \ 000 \ 000 \le M \le 1 \ 000 \ 000 \ 007.
  • MM is prime.
# Score Restrictions
0 0 Examples
1 12 N8N \le 8.
2 11 N500N \le 500.
3 26 N2 000N \le 2 \ 000.
4 51 No additional limitations.

Example 1

stdin

3 1000000007 

stdout

15 9 9 15

Example 2

stdin

7 100000007 

stdout

135135 72765 59535 55125 55125 59535 72765 135135

Log in or sign up to be able to send submissions!