#include "bits/stdc++.h" using namespace std; long long dp[1002][1002][2][2]; int mod = 1000000007; int main() { dp[0][0][0][0] = 1; int N; cin >> N; for (int i = 0; i < N; i++) { for (int j = 0; j <= i; j++) { for (int k = 0; k < 2; k++) { for (int l = 0; l < 2; l++) { if (!dp[i][j][k][l]) continue; if (k == 0){ int nokori = i + 1; dp[i + 1][j - 1][0][0] += dp[i][j][k][l]; dp[i + 1][j - 1][l][0] += dp[i][j][k][l] * (j - 1); dp[i + 1][j - 1][0][0] %= mod; dp[i + 1][j - 1][l][0] %= mod; nokori -= j; if (i >= 2){ dp[i + 1][j + 1][l][1] += dp[i][j][k][l] * 2; dp[i + 1][j + 1][l][1] %= mod; nokori -= 2; } dp[i + 1][j][l][0] += dp[i][j][k][l] * nokori; dp[i + 1][j][l][0] %= mod; } else{ int nokori = i + 1; dp[i + 1][j - 1][0][0] += dp[i][j][k][l]; dp[i + 1][j - 1][l][0] += dp[i][j][k][l] * (j - 2); dp[i + 1][j - 1][0][0] %= mod; dp[i + 1][j - 1][l][0] %= mod; nokori -= (j - 1); if (i >= 2){ dp[i + 1][j + 1][l][1] += dp[i][j][k][l]; dp[i + 1][j + 1][l][1] %= mod; dp[i + 1][j][l][1] += dp[i][j][k][l]; dp[i + 1][j][l][1] %= mod; nokori -= 2; } dp[i + 1][j][l][0] += dp[i][j][k][l] * nokori; dp[i + 1][j][l][0] %= mod; } } } } } dp[N][0][0][0] %= mod; dp[N][0][0][0] += mod; dp[N][0][0][0] %= mod; cout << dp[N][0][0][0] << endl; }