#include <iostream>
#include <sstream>
#include <algorithm>
#include <cstdio>
#include <math.h>
#include <set>
#include <map>
#include <queue>
#include <string>
#include <string.h>
#include <bitset>
#define REP(i,a,n) for(int i=a;i<=n;++i)
#define PER(i,a,n) for(int i=n;i>=a;--i)
#define hr putchar(10)
#define pb push_back
#define lc (o<<1)
#define rc (lc|1)
#define mid ((l+r)>>1)
#define ls lc,l,mid
#define rs rc,mid+1,r
#define x first
#define y second
#define io std::ios::sync_with_stdio(false)
#define endl '\n'
#define DB(a) ({REP(__i,1,n) cout<<a[__i]<<' ';hr;})
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
const int P = 1e9+7, INF = 0x3f3f3f3f;
ll gcd(ll a,ll b) {return b?gcd(b,a%b):a;}
ll qpow(ll a,ll n) {ll r=1%P;for (a%=P;n;a=a*a%P,n>>=1)if(n&1)r=r*a%P;return r;}
ll inv(ll x){return x<=1?1:inv(P%x)*(P-P/x)%P;}
inline int rd() {int x=0;char p=getchar();while(p<'0'||p>'9')p=getchar();while(p>='0'&&p<='9')x=x*10+p-'0',p=getchar();return x;}
//head



const int N = 2010, M = 4e6+10;
int n, k, dp[N][N];
int fac[M], ifac[M];
int C(int n, int m) {
	if (n<m) return 0;
	return (ll)fac[n]*ifac[m]%P*ifac[n-m]%P;
}
int main() {
	fac[0]=1;
	REP(i,1,M-1) fac[i]=(ll)fac[i-1]*i%P;
	ifac[M-1]=inv(fac[M-1]);
	PER(i,0,M-2) ifac[i]=(ll)ifac[i+1]*(i+1)%P;
	scanf("%d%d", &n, &k);
	if (k==1) return puts("1"),0;
	dp[0][0] = 1;
	REP(i,0,n) REP(j,0,i) {
		dp[i+1][j] = (dp[i+1][j]+dp[i][j])%P;
		dp[i][j+1] = (dp[i][j+1]+(ll)C(n*k-j*(k-1)-i-1,k-2)*dp[i][j])%P;
	}
	int ans = (ll)dp[n][n]*fac[n]%P;
	printf("%d\n", ans);
}







#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
using namespace std;
typedef long long int ll;
typedef pair<int,int> P;
#define yn {puts("Yes");}else{puts("No");}
#define MAX_X 200005

const int MAX = 510000;
const int MOD = 1000000007;
long long fac[MAX], finv[MAX], inv[MAX];
// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}
// 二項係数計算
long long COM(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

long long FINV(int n){
    if (n < 0) return 0;
    return finv[n];
}

ll dp[MAX_X];

int main() {
    int n, x;
    cin >> n >> x;
    int a[n];
    rep(i,n)cin >> a[i];
    sort(a,a+n);

    COMinit();

    int ite = lower_bound(a,a+n,x+1) - a;
    ite = n - ite;

    dp[x] = COM(n, ite) * fac[ite] % MOD;

    drep(i,MAX_X){
        if(dp[i] == 0)continue;
        if(i < a[0])break;
        drep(j,n){
            if(a[j] > i)continue;
            int after = i % a[j];
            int nn = 0;
            int kk = 0;
            rep(k,n){
                if(a[k] <= i){
                    nn++;
                    if(after < a[k])kk++;
                }
            }
            nn--;
            kk--;
            // cout << i << ' ' << a[j] << ' ' << after << ' ' << kk << ' ' << dp[i] * COM(nn, kk) << endl;
            dp[after] += dp[i] * COM(nn, kk) % MOD * fac[kk];
            dp[after] %= MOD;
        }
    }

    ll ans = 0;
    rep(i,a[0]){
        ans += dp[i] * i;
        ans %= MOD;
    }

    cout << ans << endl;
    return 0;
}

