#include <bits/stdc++.h>

using namespace std;
#define int long long
const int N = 4e6 + 10, M = 2e3 + 10, MOD = 1e9 + 7;
int fac[N], inv[N], dp[M][M], ps[M][M];

int sum(int a, int b) {return (a + b) % MOD;}
int mul(int a, int b) {return (a * b) % MOD;}
int Pow(int a, int b)
{
    int res = 1;
    for (; b; b>>=1, a = mul(a, a)) if (b & 1) res = mul(res, a);
    return res;
}

int C(int n, int k)
{
    if (k < 0 || n < 0 || k > n) return 0;
    return mul(fac[n], mul(inv[k], inv[n - k]));
}


int32_t main()
{
    fac[0] = 1;
    for (int i = 1; i < N; i++) fac[i] = mul(fac[i - 1], i);
    inv[N - 1] = Pow(fac[N - 1], MOD - 2);
    for (int i = N - 2; i >= 0; i--) inv[i] = mul(inv[i + 1], i + 1);
    int n, k; cin >> n >> k;
    if (k == 1) return cout << "1\n", 0;
    ps[1][1] = dp[1][1] = 1;
    for (int i = 2; i <= n; i++) {
        dp[i][1] = mul(ps[i - 1][1], C(i * k - 2, k - 2));
        for (int j = 2; j <= i; j++) {
            dp[i][j] = mul(ps[i - 1][j - 1], C(i * k - j - 1, k - 2));
        }
        for (int j = i; j >= 1; j--) ps[i][j] = sum(ps[i][j + 1], dp[i][j]);
    }
    cout << mul(ps[n][1], fac[n]) << "\n";
}

#include<bits/stdc++.h>
#define ll long long
using namespace std;
template<typename T>
void read(T &x)
{
    x=0;char c=getchar();bool p=0;
    for(;c<'0'||c>'9';c=getchar())if(c=='-')p=1;
    for(;c>='0'&&c<='9';c=getchar())x=(x<<3)+(x<<1)+(c^48);
    if(p)x=-x;
}
const ll MOD=1000000000+7;
ll f[2005][2005];
ll fac[4000005],inv[4000005];
int n,k;
ll ksm(ll basic,ll mi)
{
    ll tmp=1;
    while(mi)
    {
        if(mi&1)tmp=tmp*basic%MOD;
        mi>>=1;
        basic=basic*basic%MOD;
    }
    return tmp;
}
ll C(ll x,ll y)
{
    return fac[x]*inv[y]%MOD*inv[x-y]%MOD;
}
int main()
{
    read(n),read(k);
    fac[0]=inv[0]=1;
    for(ll i=1;i<=n*k;++i)fac[i]=fac[i-1]*i%MOD;
    inv[n*k]=ksm(fac[n*k],MOD-2);
    for(ll i=n*k-1;i;--i)inv[i]=inv[i+1]*(i+1)%MOD;
    if(k==1)
    {
        printf("1\n");
        return 0;
    }
    f[0][0]=1;
    for(int i=1;i<=n;++i)
    {
        f[i][0]=1;
        for(int j=1;j<=i;++j)
        {
            f[i][j]=(f[i][j]+f[i-1][j]+1ll*f[i][j-1]*(n-j+1)%MOD*C(n*k-i-(j-1)*(k-1)-1,k-2)%MOD)%MOD;
        }
    }
    printf("%lld\n",f[n][n]);
    return 0;
}