spoj#CPDUEL5C. Phasmophobia
Phasmophobia
Okayu and Korone are playing Phasmophobia.
There are N rooms, numbered 1 to N. Each player has to enter the N rooms in an order.
Let P be the permutation of size N representing the order of rooms Okayu enters, and Q for Korone.
Korone doesn't want to be too far from Okayu, so they set up a plan as the following:
- Okayu will enter the rooms in numerical order. Formally, P = {1, 2, 3, ..., N}.
- Korone will enter the rooms in a way such that |Pi - Qi| ≤ K for every 1 ≤ i ≤ N.
How many configurations can Korone enter the rooms? Since the answer can be large, print the answer modulo 109 + 7.
Input Format
The first and only line contains two integers N and K.
Output Format
Print an integer denoting the number of permutations Q satisfying the conditions above in modulo 109 + 7.
Sample Input 1
3 1
Sample Output 1
3
Sample Input 2
3 2
Sample Output 2
6
Explanation
In sample 1, the possible configurations are {1, 2, 3}, {2, 1, 3}, and {1, 3, 2}.
In sample 2, all permutations are valid.
Constraints
1 ≤ N ≤ 1000
1 ≤ K ≤ 5