/*
   题意:
       dp[n,k] 表示n个数有k个ai>i
       考虑第n个数
       数n与前面任何一个ai<=i的交换,E-value增大1
       数n与前面任何一个ai>i的交换或者an = n,E-value不变
       dp[n,k] = (n-1-(k-1))*dp[n-1,k-1] + (k+1)*dp[n-1,k]
               = (n-k)*dp[n-1,k-1] + (k+1)*dp[n-1,k]
 
*/
#include
<cstdio>
#include
<cstring>
#include
<algorithm>
#include
<cmath>

using namespace std;

const int MOD = 1000000007;

int dp[1010][1010];

void init()
{
    dp[
0][0= 1;
    
for(int n=1;n<=1000;n++)
        
for(int k=0;k<=n;k++)
        {
            dp[n][k] 
= ((long long)(k+1)*dp[n-1][k])%MOD;
            
if(k)
                dp[n][k] 
= (dp[n][k] + (long long)(n-k)*dp[n-1][k-1])%MOD;
        }
}
int main()
{
   
// freopen("in","r",stdin);
    init();
    
int N,K;
    
while(~scanf("%d%d",&N,&K))
    {
        printf(
"%d\n",dp[N][K]);
    }
    
return 0;
}