atcoder#ARC068D. [ARC068F] Solitaire

[ARC068F] Solitaire

Score : 12001200 points

Problem Statement

Snuke has decided to play with NN cards and a deque (that is, a double-ended queue). Each card shows an integer from 11 through NN, and the deque is initially empty.

Snuke will insert the cards at the beginning or the end of the deque one at a time, in order from 11 to NN. Then, he will perform the following action NN times: take out the card from the beginning or the end of the deque and eat it.

Afterwards, we will construct an integer sequence by arranging the integers written on the eaten cards, in the order they are eaten. Among the sequences that can be obtained in this way, find the number of the sequences such that the KK-th element is 11. Print the answer modulo 109+710^{9} + 7.

Constraints

  • 1KN2,0001 \leq K \leq N \leq 2{,}000

Input

The input is given from Standard Input in the following format:

NN KK

Output

Print the answer modulo 109+710^{9} + 7.

2 1
1

There is one sequence satisfying the condition: 1,21,2. One possible way to obtain this sequence is the following:

  • Insert both cards, 11 and 22, at the end of the deque.
  • Eat the card at the beginning of the deque twice.
17 2
262144
2000 1000
674286644