#include <bits/stdc++.h>
using namespace std;
const int mod = 1e9 + 7;
long long f[1005][1005][5];
int main() {
  int n, k;
  scanf("%d%d", &n, &k);
  f[1][0][4] = 1;
  for (int i = 1; i < n; i++) {
    for (int j = 0; j <= i; j++) {
      for (int t = 0; t <= 3; t++) {
        int s1, s2;
        if (t == 0) s1 = i - j - 2, s2 = j;
        if (t == 1 || t == 2) s1 = i - j - 1, s2 = j - 1;
        if (t == 3) s1 = i - j, s2 = j - 2;
        f[i + 1][j][0] = (f[i + 1][j][0] + (f[i][j][t] * s1)) % mod;
        f[i + 1][j - 1][0] = (f[i + 1][j - 1][0] + (f[i][j][t] * s2)) % mod;
        f[i + 1][j + ((t & 1) ? 0 : 1)][2] =
            (f[i + 1][j + ((t & 1) ? 0 : 1)][2] + (f[i][j][t])) % mod;
        f[i + 1][j + (t < 2 ? 1 : 0)][1] =
            (f[i + 1][j + (t < 2 ? 1 : 0)][1] + (f[i][j][t])) % mod;
        f[i + 1][j][4] = (f[i + 1][j][4] + (f[i][j][t])) % mod;
      }
      f[i + 1][j][0] = (f[i + 1][j][0] + (f[i][j][4] * (i - j - 1))) % mod;
      f[i + 1][j - 1][0] = (f[i + 1][j - 1][0] + (f[i][j][4] * j)) % mod;
      f[i + 1][j + 2][3] = (f[i + 1][j + 2][3] + (f[i][j][4])) % mod;
      f[i + 1][j][4] = (f[i + 1][j][4] + (f[i][j][4])) % mod;
    }
  }
  int ans = 0;
  for (int i = 0; i <= 4; i++) ans = (ans + (f[n][k][i])) % mod;
  printf("%d", ans);
}
