Problem:
Score : 1200 points

Problem Statement

Snuke has decided to play with N cards and a deque (that is, a double-ended queue).
Each card shows an integer from 1 through N, 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 1 to N.
Then, he will perform the following action N 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 K-th element is 1. Print the answer modulo 10^{9} + 7.

Constraints

1 ≦ K ≦ N ≦ 2{,}000

Input

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

N K

Output

Print the answer modulo 10^{9} + 7.

Sample Input 1

2 1

Sample Output 1

1

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

Insert both cards, 1 and 2, at the end of the deque.

Eat the card at the beginning of the deque twice.

Sample Input 2

17 2

Sample Output 2

262144

Sample Input 3

2000 1000

Sample Output 3

674286644

Solution in C++14 (GCC 5.4.1) (judge verdict: Accepted)

#include<bits/stdc++.h>
#define fi first
#define se second
#define pb push_back
#define SZ(x) ((int)x.size())
#define L(i,u) for (register int i=head[u]; i; i=nxt[i])
#define rep(i,a,b) for (register int i=(a); i<=(b); i++)
#define per(i,a,b) for (register int i=(a); i>=(b); i--)
using namespace std;
typedef long long ll;
typedef unsigned int ui;
typedef pair<int,int> Pii;
typedef vector<int> Vi;
template<class T> inline void read(T &x){
	x=0; char c=getchar(); int f=1;
	while (!isdigit(c)) {if (c=='-') f=-1; c=getchar();}
	while (isdigit(c)) {x=x*10+c-'0'; c=getchar();} x*=f;
}
template<class T> inline void umin(T &x, T y){x=x<y?x:y;}
template<class T> inline void umax(T &x, T y){x=x>y?x:y;}
inline ui R() {
	static ui seed=416;
	return seed^=seed>>5,seed^=seed<<17,seed^=seed>>13;
}
const int N = 2333,mo=1e9+7;
int n,k,C[N][N],res,f[N][N],g[N];
void ini(int n){
	rep(i,2,n+1)f[n][i]=1;
	per(i,n-1,1){
		int s=f[i+1][2];
		rep(j,2,i+1)
			s=(s+f[i+1][j+1])%mo,f[i][j]=s;
	}
	rep(i,1,n)g[i]=f[i][i+1];g[0]=g[1];
}
int main() {
	read(n);read(k);
	rep(i,0,n){
		C[i][0]=C[i][i]=1;
		rep(j,1,i-1)C[i][j]=(C[i-1][j-1]+C[i-1][j])%mo;
	}
	ini(k-1);
	if(k==1)res=1;
	else if(k==n)res=g[0];
	else{rep(i,n-k,n-1)res=(res+1LL*C[i-1][n-k-1]*g[i-(n-k)])%mo;}
	rep(i,1,n-k-1)res=2LL*res%mo;
	cout<<res;
	return 0;
}