#pragma GCC optimize("O3,inline,unroll-loops")
#include <iostream>
#include <algorithm>
#include <cstdio>
#define N 20000020
#define MOD 1000000007
using namespace std;

namespace Comb
{
    int f[N], g[N];
 
    int Power(int x, int y)
    {
        int o;
 
        for(o = 1; y; y >>= 1)
        {
            if(y & 1)
                o = (long long)o * x % MOD;
            x = (long long)x * x % MOD;
        }
 
        return o;
    }
 
    void InitComb(void)
    {
        int i;
 
        for(i = f[0] = 1; i < N; i ++)
            f[i] = (long long)f[i - 1] * i % MOD;
        g[N - 1] = Power(f[N - 1], MOD - 2);
        for(i = N - 2; i > -1; i --)
            g[i] = (long long)g[i + 1] * (i + 1) % MOD;
 
        return;
    }

    int C(int n, int m)
    {
        return n >= m ? (long long)f[n] * g[m] % MOD * g[n - m] % MOD : 0;
    }

    int S(int x, int y, int z)
    {
        return (long long)f[x + y + z] * g[x + y] % MOD * f[x + y - 1] % MOD * x % MOD;
    }
}

int main(void)
{
    int n, a;
    int i, j, o;

    Comb::InitComb();
    cin >> n >> a;
    for(i = o = 0; i < a; i ++)
        o = (o + (long long)(i & 1 ? MOD - 1 : 1) * Comb::C(a, i) % MOD * Comb::S(a - i, n - a, 0) % MOD) % MOD;
    for(i = 0; i < a; i ++)
        for(j = 0; j < a; j ++)
            o = (o + (long long)(j & 1 ? MOD - 1 : 1) * Comb::C(i, j) % MOD * Comb::S(i - j, n - a, a - i - 1) % MOD) % MOD;
    cout << o << endl;

    return 0;
}
