#include<iostream>
#include<istream>
#include<iomanip>
#include<map>
#include<set>
#include<vector>
#include<string>
#include<stack>
#include<array>
#include<queue>
#include<algorithm>
#include<cassert>
#include<functional>
#include<numeric>
#include<random>
#define int int64_t
#define REP(i, a, b) for (int64_t i = (int64_t)(a); i < (int64_t)(b); i++)
#define rep(i, a) REP(i, 0, a)
#define EACH(i, a) for (auto i: a)
#define ITR(x, a) for (auto x = a.begin(); x != a.end(); x++)
#define ALL(a) (a.begin()), (a.end())
#define HAS(a, x) (a.find(x) != a.end())
#define pb(x) push_back(x)
#define mp(x,y) std::make_pair((x),(y))
using namespace std;

template<int MOD = 1000000007>class modint {
	//MODが素数であることを前提として実装してあるが、その判定はしていない。
	//あまりが出るような除算をしてはいけない。
public:
	modint() {
		//assert(is_prime(MOD));
		this->number = 0;
	}
	modint(const int src) {
		//assert(is_prime(MOD));
		this->number = opposit(src);
	}
	modint(const modint<MOD> &src) {
		this->number = src.number;
	}

	modint<MOD>& operator += (const modint<MOD>& obj) {
		this->number = san2(this->number + obj.number);
		return *this;
	}
	modint<MOD>& operator -= (const modint<MOD>& obj) {
		this->number = san2(this->number - obj.number + MOD);
		return *this;
	}
	modint<MOD>& operator *= (const modint<MOD>& obj) {
		this->number = (this->number * obj.number) % MOD;
		return *this;
	}
	modint<MOD>& operator /= (const modint<MOD>& obj) {
		this->number = (this->number * inverse(obj.number)) % MOD;
		return *this;
	}
	modint<MOD>& operator += (const int n) {
		this->number = san2(this->number + opposit(n));
		return *this;
	}
	modint<MOD>& operator -= (const int n) {
		this->number = san2(this->number - opposit(n) + MOD);
		return *this;
	}
	modint<MOD>& operator *= (const int n) {
		this->number = (this->number * opposit(n)) % MOD;
		return *this;
	}
	modint<MOD>& operator /= (const int n) {
		this->number = (this->number * inverse(n)) % MOD;
		return *this;
	}

	modint<MOD> operator + (const modint<MOD> obj) { modint<MOD>re(*this); return re += obj; }
	modint<MOD> operator - (const modint<MOD> obj) { modint<MOD>re(*this); return re -= obj; }
	modint<MOD> operator * (const modint<MOD> obj) { modint<MOD>re(*this); return re *= obj; }
	modint<MOD> operator / (const modint<MOD> obj) { modint<MOD>re(*this); return re /= obj; }
	modint<MOD> operator + (const int n) { modint<MOD>re(*this); return re += n; }
	modint<MOD> operator - (const int n) { modint<MOD>re(*this); return re -= n; }
	modint<MOD> operator * (const int n) { modint<MOD>re(*this); return re *= n; }
	modint<MOD> operator / (const int n) { modint<MOD>re(*this); return re /= n; }

	modint<MOD> operator = (const int n) {
		this->number = opposit(n);
		return *this;
	}
	int get() {
		return number;
	}

private:
	int number;

	int opposit(int n) {
		if (n < 0)n = MOD - ((-n) % MOD);
		return n % MOD;
	}
	int inverse(int n) {
		n = opposit(n);
		int result = 1;
		for (int i = MOD - 2; i; i /= 2) {
			if (i % 2)result = (result * n) % MOD;
			n = (n * n) % MOD;
		}
		return result;
	}
	inline int san2(const int n) {
		return MOD <= n ? n - MOD : n;
	}
	bool is_prime(int n) {
		if (n <= 1)return false;
		if (n == 2)return true;
		if (n % 2 == 0) return false;
		const int upperbound = sqrt(n);
		for (int i = 3; i <= upperbound; i += 2) {
			if (n % i == 0) return false;
		}
		return true;
	}
};

vector<modint<>> factorial;

modint<> combination(int a, int b) {
	return factorial[a] / (factorial[a - b] * factorial[b]);
}

signed main() {
	std::cin.tie(0);
	std::ios::sync_with_stdio(false);

	int N, K;
	cin >> N >> K;
	if (K == 1) {
		cout << 1 << endl;
		return 0;
	}

	factorial.resize(2000*2000);
	factorial[0] = 1;
	factorial[1] = 1;
	REP(i, 2, factorial.size())factorial[i] = factorial[i - 1] * i;

	vector<vector<modint<>>> dp(N + 1);//dp[i][j]:=解説の通り
	rep(i, N + 1)dp[i].resize(N + 1);
	dp[0][0] = 1;

	for (int j = 0; j <= N; j++)for (int i = 0; i <= j; i++) {
		if (i != 0) {
			dp[i][j] += dp[i - 1][j];
		}
		if (j != 0) {
			const int position = i + j * (K - 1) - 1;
			dp[i][j] += dp[i][j - 1] * combination(position, K - 2);
		}
	}

	cout << (dp[N][N] * factorial[N]).get() << endl;
}



Measured memory_bytes: 62848