#include #include #include #include #include using namespace std; #define MOD 1000000007 int vals[1500]; long long int dp[1500][1500]; bool valid[1500][1500]; long long int fact[1500],ifact[1500]; int main() { fact[0] = ifact[0] = ifact[1] = fact[1] = 1; for(int i=2;i<1500;i++) ifact[i] = (MOD - (MOD/i) * ifact[MOD%i] % MOD) % MOD; for(int i=2;i<1500;i++){ fact[i] = (i*fact[i-1])%MOD; ifact[i] = (ifact[i-1]*ifact[i])%MOD; } int M;cin>>M; for(int i=0;i>vals[i]; for(int i=0;i=0;j--){ dp[i][j] = 0; if(j+i-1 >= M || !valid[j][j+i-1]) continue; long long int total = 0; for(int k=0;k<=i && i+j <= M;k++) dp[i][j] = (dp[i][j] + (( fact[i]*ifact[i-k])%MOD)*dp[k][j+i])%MOD; } //for(int i=0;i<=M;i++,cout<