Public Judge

pjudge

حد الوقت: 0.5 s حد الذاكرة: 512 MB مجموع النقاط: 7 قابلة للهجوم ✓

#21630. 【PER #1】Bracket Sequence

الإحصائيات

Given positive integers $N$ and $M$, there are $N$ pairs of distinct parentheses. Arranging them in any order results in a sequence of parentheses, with a total of $(2N)!$ possible permutations.

A sequence of parentheses is called valid if and only if the difference between the indices of each pair of parentheses is not a multiple of $M$.

Find the number of valid parenthesis sequences modulo $10^9+7$.

Input

A single line containing two positive integers $N$ and $M$.

Output

A single line containing a non-negative integer representing the answer.

Examples

Input 1

1 1

Output 1

0

Input 2

3 2

Output 2

288

Input 3

300 300

Output 3

929890502

Input 4

100 23

Output 4

171243255

Input 5

2000 1000

Output 5

348739341

Constraints

For all test cases, $M\le N\le 2000$.

Subtask ID $N\le$ Score
$1$ $5$ $1$
$2$ $100$ $1$
$3$ $300$ $1$
$4$ $900$ $2$
$5$ $2000$ $2$

Discussions

About Discussions

The discussion section is only for posting: General Discussions (problem-solving strategies, alternative approaches), and Off-topic conversations.

This is NOT for reporting issues! If you want to report bugs or errors, please use the Issues section below.

Open Discussions 0
No discussions in this category.

Issues

About Issues

If you find any issues with the problem (statement, scoring, time/memory limits, test cases, etc.), you may submit an issue here. A problem moderator will review your issue.

Guidelines:

  1. This is not a place to publish discussions, editorials, or requests to debug your code. Issues are only visible to you and problem moderators.
  2. Do not submit duplicated issues.
  3. Issues must be filed in English or Chinese only.
Active Issues 0
No issues in this category.
Closed/Resolved Issues 0
No issues in this category.