Skip to main content
Tuesday (24.11.2026) at 20:00: ALGOR Contest: Round #4 (Special Challenge) starts!

~/algor $ cat problems/kombinatorika-yonma-yon-emas

Not side by side

Medium 1000 ms 128 MB 47%
Share

There are $n$ chairs in a row. Choose $k$ of them and seat $k$ students so that no two students sit on adjacent chairs. The students are considered identical: only which chairs are occupied matters. How many ways are there? Print the answer modulo $10^{9} + 7$.

Chairs in a row; at least one empty chair between the chosen ones

Input

One line with two integers: $n$ and $k$.

Output

One integer — the number of ways modulo $10^{9} + 7$.

Note

$1 \le n \le 10^{6}$
$0 \le k \le n$

Examples

Input #1
5 2
Output #1
6
Input #2
3 3
Output #2
0

Sign in to submit a solution

Signing up is free and takes a minute.