#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define rrep(ri,n) for(int ri = (int)(n-1); ri >= 0; ri--)
#define rep2(i,x,n) for(int i = (int)(x); i < (int)(n); i++)
#define repit(itr,x) for(auto itr = x.begin(); itr != x.end(); itr++)
#define rrepit(ritr,x) for(auto ritr = x.rbegin(); ritr != x.rend(); ritr++)
#define ALL(x) x.begin(), x.end()
using ll = long long;
using namespace std;

int main(){
  int n, m;
  cin >> n >> m;
  n = 2*m+1;
  vector<pair<int, int>> ans;
  int r;
  if(m % 2 == 0) r = m+1;
  else r = m;
  rep(i, m/2){
    ans.push_back(make_pair(i+1, r-i));
  }
  int l;
  l = r+1;
  rep(i, (m+1)/2){
    ans.push_back(make_pair(l+i, n-i));
  }
  rep(i, m){
    cout << ans.at(i).first << " " << ans.at(i).second << endl;
  }
  return 0;
}
#include <cstdio>
#include <algorithm>
using namespace std;

const int MAXN = 3000;
const int MAXM = MAXN*MAXN;
const int MOD = int(1E9) + 7;

int pow_mod(int b, int p) {
	int ret = 1;
	for(int i=p;i;i>>=1,b=1LL*b*b%MOD)
		if( i & 1 ) ret = 1LL*ret*b%MOD;
	return ret;
}

int fct[MAXM + 5], ifct[MAXM + 5];
int comb(int n, int m) {
	return 1LL*fct[n]*ifct[m]%MOD*ifct[n-m]%MOD;
}
void init() {
	fct[0] = 1;
	for(int i=1;i<=MAXM;i++)
		fct[i] = 1LL*fct[i-1]*i%MOD;
	ifct[MAXM] = pow_mod(fct[MAXM], MOD - 2);
	for(int i=MAXM-1;i>=0;i--)
		ifct[i] = 1LL*ifct[i+1]*(i+1)%MOD;
}

int f[MAXN + 5][MAXN + 5];

int main() {
	init();
	int N, K; scanf("%d%d", &N, &K);
	if( K == 1 ) {
		puts("1");
		return 0;
	}
	for(int i=1;i<=N;i++) f[1][i] = 1;
	for(int i=2;i<=N;i++) {
		for(int j=1;j<=i;j++) {
			int m = (K - 1)*(i - 1) + j, n = K - 2;
			f[i][j] = 1LL*f[i-1][j]*comb(n+m-1, n)%MOD;
		}
		for(int j=1;j<=N;j++)
			f[i][j] = (f[i][j] + f[i][j-1]) % MOD;
	}
	printf("%lld\n", 1LL*f[N][N]*fct[N]%MOD);
}