#include<bits/stdc++.h>

using namespace std;

const int maxn = 2005;
const int maxm = 5005;
const int mod = 1e9 + 7;

int add(int x, int y) {
  x += y;
  if(x >= mod) x -= mod;
  if(x < 0) x += mod;
  return x;
}

int sub(int x, int y) {
  x -= y;
  if(x >= mod) x -= mod;
  if(x < 0) x += mod;
  return x;
}

int mult(int x, int y) {
  return 1LL * x * y % mod;
}

int binpow(int x, int y) {
  int ret = 1;
  for(; y > 0; x = mult(x, x), y >>= 1) {
    if(y & 1) ret = mult(ret, x);
  }
  return ret;
}

int inverse_modulo(int x) {
  return binpow(x, mod - 2);
}

template<int N>
struct Combinatorics{
  vector<int> fact, invfact;

  Combinatorics() {
    fact.resize(N); invfact.resize(N);
    fact[0] = 1;
    for(int i = 1; i < N; ++i) fact[i] = mult(fact[i - 1], i);
    invfact[N - 1] = inverse_modulo(fact[N - 1]);
    for(int i = N - 1; i > 0; --i) {
      invfact[i - 1] = mult(invfact[i], i);
    }
  }

  int comb(int n, int k) {
    assert(k >= 0);
    if(n < 0) return 1;
    return mult(mult(fact[n], invfact[k]), invfact[n - k]);
  }

  int catalan(int n) {
    if(n < 0) return 1;
    return mult(fact[n + n], mult(invfact[n], invfact[n + 1]));
  }
};

Combinatorics<maxm> combi;


int n, k;
int g[maxn];

int brute(int n, int req) {

  set<vector<int>> ans;
  for(int mask = 0; mask < (1 << n); ++mask) {
    if((mask | ((1 << req) - 1)) != mask) {
      continue;
    }

    vector<int> x, y;
    for(int i = 0; i < n; ++i)
      if(mask & (1 << i)) x.push_back(i);
      else y.push_back(i);


    for(int take = 0; take < (1 << n); ++take) {
      if(__builtin_popcount(take) != x.size()) continue;

      vector<int> z, xx = x, yy = y;
      for(int i = 0; i < n; ++i) if(take & (1 << i)) {
        z.push_back(xx.back());
        xx.pop_back();
      }
      else {
        z.push_back(yy.back());
        yy.pop_back();
      }
      ans.insert(z);
    }
  }

//  cout << ans << endl;
  return ans.size();
}

int convolution(int n, int k) {
  return mult(combi.comb(2 * n - k, n), mult(k, inverse_modulo(2 * n - k)));
}

int dp[maxn][maxn];

int main() {
  ios_base::sync_with_stdio(false); cin.tie(NULL);

    cin >> n >> k;

//  cout << combi.comb(7, 3) << endl;
  // g[0] = combi.catalan(k - 1);
  // for(int i = 1; i < k; ++i) {
  //   for(int j = 0; j + i < k; ++j) {
  //     int d = k - 1 - i - j;
  //     int c = combi.catalan(d);
  //     g[i] = add(g[i], mult(c, combi.comb(i + j - 1, j)));
  //   }
  //   g[i] = brute(k - 1, i);
  // }
  //
  //
  // dp[0][0] = 1;
  // for(int sum = 1; sum < k; ++sum) {
  //   dp[sum][0] = combi.catalan(sum);
  //   for(int need = 1; need <= sum; ++need) {
  //     dp[sum][need] = dp[sum - need][0];
  //     for(int will = 1; will <= sum - need; ++will) {
  //       for(int t = will; t <= sum - need; ++t) {
  //         dp[sum][need] = add(dp[sum][need], mult(dp[sum - need - will][t - will], mult(combi.comb(t - 1, will - 1), combi.comb(need - 1 + will, will))));
  //       }
  //     }
  //   }
  // }
  //
  //
  // for(int i = 0; i < k; ++i) {
  //   cout << dp[k - 1][i] << " " << convolution(k, i + 1) << endl;
  // }
  //
  // for(int i = 0; i < k; ++i) {
  //
  //   cout << i << " " << g[i] << " " << dp[k - 1][i] << endl;
  //   g[i] = dp[k - 1][i];
  // }

  /// aba
  /// aab
  /// baa
//  return 0;

  //cout << g[0] << endl;

  int ans = 0;
  if(k == n) {
    ans = combi.catalan(n - 1);
  }
  else {
    for(int i = n - k + 1; i <= n; ++i) {
      int c = combi.comb(i - 2, n - k - 1);
    //  cout << c << " " << (i - (n - k) - 1) << " " << g[i - (n - k) - 1] << endl;

      int d = i - (n - k) - 1;
      c = mult(c, convolution(k, d + 1));
      ans = add(ans, c);
    }
  }

//  cout << mult(3268608, inverse_modulo(binpow(2, n - k - 1))) << endl;
  //cout << ans << endl;
//  cout << binpow(2, n - k - 1) << endl;
  ans = mult(ans, binpow(2, n - k - 1));

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 256