stablegradients/pie-gem5-pairs huggingface dataset:
// Slower C++ solution:
#include<bits/stdc++.h>

using namespace std;



typedef long long ll;

typedef double dd;

typedef vector<int> vi;

typedef vector<ll> vl;

typedef pair<int,int> pii;



const int mx=1e6+11;

const double PI = acos(-1);

#define MOD 1000000007





#define nl '\n'

#define pb push_back

#define F first

#define S second

#define I insert

#define mp make_pair



#define sz(x) x.size()

#define tt int t; cin>>t; while(t--)

#define lo(i,a,b) for(int i=a;i<b;i++)

#define be(a) (a).begin(),(a).end()

#define rbe(a) (a).rbegin(),(a).rend()

#define mem(a,b) memset(a,b,sizeof(a))



#define su ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);

#define file freopen("input.txt","r",stdin);freopen("output.txt","w",stdout);

#define frac cout.unsetf(ios::floatfield); cout.precision(10); cout.setf(ios::fixed,ios::floatfield);



#define dbg(args...) do {cerr << #args << " : "; faltu(args); } while(0)

void faltu () {            cerr << endl;}

template < typename T, typename ... hello>void faltu( T arg, const hello &... rest) {cerr << arg << ' ';faltu(rest...);}





int main()

{

   su;

   int a,b;

   cin>>a>>b;

   if(b%a)

    cout<<b-a<<nl;

   else

    cout<<a+b<<nl;

   return 0;

}


// Faster C++ solution for the same problem (measured speedup: 5.329756692730132x):
#include<stdio.h>

int main(){

    int a, b;

    scanf("%d %d", &a, &b);

    if(b % a == 0){

        printf("%d\n",a + b);

    }

    else{

        printf("%d\n", b - a);

    }

    return 0;

}
// Slower C++ solution:
#include<iostream>

using namespace std;

int main ()

{

    int a,b;

    cin>>a>>b;

    if (b%a==0)

        cout<<a+b<<endl;

    else

        cout<<b-a<<endl;

    return 0;

}


// Faster C++ solution for the same problem (measured speedup: 5.268166540350466x):
#include<stdio.h>

int main(){

	int A;

	int B;

	int result;

	scanf("%d %d", &A, &B);

	if(B%A ==0){

		printf("%d", A + B);

	}else{

		printf("%d", B-A);

	}

	return 0;

}
// Slower C++ solution:
#include<bits/stdc++.h>

using namespace std;



typedef long long ll;

typedef double dd;

typedef vector<int> vi;

typedef vector<ll> vl;

typedef pair<int,int> pii;



const int mx=1e6+11;

const double PI = acos(-1);

#define MOD 1000000007





#define nl '\n'

#define pb push_back

#define F first

#define S second

#define I insert

#define mp make_pair



#define sz(x) x.size()

#define tt int t; cin>>t; while(t--)

#define lo(i,a,b) for(int i=a;i<b;i++)

#define be(a) (a).begin(),(a).end()

#define rbe(a) (a).rbegin(),(a).rend()

#define mem(a,b) memset(a,b,sizeof(a))



#define su ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);

#define file freopen("input.txt","r",stdin);freopen("output.txt","w",stdout);

#define frac cout.unsetf(ios::floatfield); cout.precision(10); cout.setf(ios::fixed,ios::floatfield);



#define dbg(args...) do {cerr << #args << " : "; faltu(args); } while(0)

void faltu () {            cerr << endl;}

template < typename T, typename ... hello>void faltu( T arg, const hello &... rest) {cerr << arg << ' ';faltu(rest...);}





int main()

{

   su;

   int a,b;

   cin>>a>>b;

   if(b%a)

    cout<<b-a<<nl;

   else

    cout<<a+b<<nl;

   return 0;

}


// Faster C++ solution for the same problem (measured speedup: 5.336212479220605x):
#include<stdio.h>

int main(){

	int A;

	int B;

	int result;

	scanf("%d %d", &A, &B);

	if(B%A ==0){

		printf("%d", A + B);

	}else{

		printf("%d", B-A);

	}

	return 0;

}
// Slower C++ solution:
#include<iostream>

using namespace std;

int main ()

{

    int a,b;

    cin>>a>>b;

    if (b%a==0)

        cout<<a+b<<endl;

    else

        cout<<b-a<<endl;

    return 0;

}


// Faster C++ solution for the same problem (measured speedup: 5.268166540350466x):
#include <stdio.h>



int main (){

    int v,e,n;

    scanf ("%d %d",&v , &e);

    if (e%v==0){

    	printf ("%d",v+e);

    	

	}else{

		printf ("%d",e-v);

	}

   return 0;

}
// Slower C++ solution:
#include<bits/stdc++.h>

using namespace std;



typedef long long ll;

typedef double dd;

typedef vector<int> vi;

typedef vector<ll> vl;

typedef pair<int,int> pii;



const int mx=1e6+11;

const double PI = acos(-1);

#define MOD 1000000007





#define nl '\n'

#define pb push_back

#define F first

#define S second

#define I insert

#define mp make_pair



#define sz(x) x.size()

#define tt int t; cin>>t; while(t--)

#define lo(i,a,b) for(int i=a;i<b;i++)

#define be(a) (a).begin(),(a).end()

#define rbe(a) (a).rbegin(),(a).rend()

#define mem(a,b) memset(a,b,sizeof(a))



#define su ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);

#define file freopen("input.txt","r",stdin);freopen("output.txt","w",stdout);

#define frac cout.unsetf(ios::floatfield); cout.precision(10); cout.setf(ios::fixed,ios::floatfield);



#define dbg(args...) do {cerr << #args << " : "; faltu(args); } while(0)

void faltu () {            cerr << endl;}

template < typename T, typename ... hello>void faltu( T arg, const hello &... rest) {cerr << arg << ' ';faltu(rest...);}





int main()

{

   su;

   int a,b;

   cin>>a>>b;

   if(b%a)

    cout<<b-a<<nl;

   else

    cout<<a+b<<nl;

   return 0;

}


// Faster C++ solution for the same problem (measured speedup: 5.336212479220605x):
#include <stdio.h>



int main (){

    int v,e,n;

    scanf ("%d %d",&v , &e);

    if (e%v==0){

    	printf ("%d",v+e);

    	

	}else{

		printf ("%d",e-v);

	}

   return 0;

}
// Slower C++ solution:
#include<iostream>

using namespace std;

int main ()

{

    int a,b;

    cin>>a>>b;

    if (b%a==0)

        cout<<a+b<<endl;

    else

        cout<<b-a<<endl;

    return 0;

}


// Faster C++ solution for the same problem (measured speedup: 5.26913791361307x):
#include <stdio.h>



int main() {

	int A,B;

	scanf("%d%d",&A,&B);

	if(B%A==0){

		printf("%d",B+A);

		

	}else{

		printf("%d",B-A);

	}

	return 0;

}
// Slower C++ solution:
#include<bits/stdc++.h>

using namespace std;



typedef long long ll;

typedef double dd;

typedef vector<int> vi;

typedef vector<ll> vl;

typedef pair<int,int> pii;



const int mx=1e6+11;

const double PI = acos(-1);

#define MOD 1000000007





#define nl '\n'

#define pb push_back

#define F first

#define S second

#define I insert

#define mp make_pair



#define sz(x) x.size()

#define tt int t; cin>>t; while(t--)

#define lo(i,a,b) for(int i=a;i<b;i++)

#define be(a) (a).begin(),(a).end()

#define rbe(a) (a).rbegin(),(a).rend()

#define mem(a,b) memset(a,b,sizeof(a))



#define su ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);

#define file freopen("input.txt","r",stdin);freopen("output.txt","w",stdout);

#define frac cout.unsetf(ios::floatfield); cout.precision(10); cout.setf(ios::fixed,ios::floatfield);



#define dbg(args...) do {cerr << #args << " : "; faltu(args); } while(0)

void faltu () {            cerr << endl;}

template < typename T, typename ... hello>void faltu( T arg, const hello &... rest) {cerr << arg << ' ';faltu(rest...);}





int main()

{

   su;

   int a,b;

   cin>>a>>b;

   if(b%a)

    cout<<b-a<<nl;

   else

    cout<<a+b<<nl;

   return 0;

}


// Faster C++ solution for the same problem (measured speedup: 5.337196399164325x):
#include <stdio.h>



int main() {

	int A,B;

	scanf("%d%d",&A,&B);

	if(B%A==0){

		printf("%d",B+A);

		

	}else{

		printf("%d",B-A);

	}

	return 0;

}
// Slower C++ solution:
#include<iostream>

using namespace std;

int main ()

{

    int a,b;

    cin>>a>>b;

    if (b%a==0)

        cout<<a+b<<endl;

    else

        cout<<b-a<<endl;

    return 0;

}


// Faster C++ solution for the same problem (measured speedup: 5.269072940122495x):
#include <stdio.h>



int main() {

    int A,B;

    scanf("%d%d",&A,&B);

    if(B%A==0){

        printf("%d",B+A);



    }else{

        printf("%d",B-A);

    }

    return 0;

}
// Slower C++ solution:
#include<bits/stdc++.h>

using namespace std;



typedef long long ll;

typedef double dd;

typedef vector<int> vi;

typedef vector<ll> vl;

typedef pair<int,int> pii;



const int mx=1e6+11;

const double PI = acos(-1);

#define MOD 1000000007





#define nl '\n'

#define pb push_back

#define F first

#define S second

#define I insert

#define mp make_pair



#define sz(x) x.size()

#define tt int t; cin>>t; while(t--)

#define lo(i,a,b) for(int i=a;i<b;i++)

#define be(a) (a).begin(),(a).end()

#define rbe(a) (a).rbegin(),(a).rend()

#define mem(a,b) memset(a,b,sizeof(a))



#define su ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);

#define file freopen("input.txt","r",stdin);freopen("output.txt","w",stdout);

#define frac cout.unsetf(ios::floatfield); cout.precision(10); cout.setf(ios::fixed,ios::floatfield);



#define dbg(args...) do {cerr << #args << " : "; faltu(args); } while(0)

void faltu () {            cerr << endl;}

template < typename T, typename ... hello>void faltu( T arg, const hello &... rest) {cerr << arg << ' ';faltu(rest...);}





int main()

{

   su;

   int a,b;

   cin>>a>>b;

   if(b%a)

    cout<<b-a<<nl;

   else

    cout<<a+b<<nl;

   return 0;

}


// Faster C++ solution for the same problem (measured speedup: 5.337130586447781x):
#include <stdio.h>



int main() {

    int A,B;

    scanf("%d%d",&A,&B);

    if(B%A==0){

        printf("%d",B+A);



    }else{

        printf("%d",B-A);

    }

    return 0;

}
// Slower C++ solution:
#include<bits/stdc++.h>

#define LL long long

#define db double



using namespace std;

const int N=2000+10,mod=1e9+7;

int rd()

{

    int x=0,w=1;char ch=0;

    while(ch<'0'||ch>'9'){if(ch=='-') w=-1;ch=getchar();}

    while(ch>='0'&&ch<='9'){x=x*10+(ch^48);ch=getchar();}

    return x*w;

}

void ad(int &x,int y){x+=y,x-=x>=mod?mod:0;}

int fpow(int a,int b){int an=1;while(b){if(b&1) an=1ll*an*a%mod;a=1ll*a*a%mod,b>>=1;}return an;}

int ginv(int a){return fpow(a,mod-2);}

int n,k,fac[N*N],iac[N*N],f[2][N];

int C(int a,int b){return b<0||a<b?0:1ll*fac[a]*iac[b]%mod*iac[a-b]%mod;}



int main()

{

	n=rd(),k=rd();

	if(k==1){puts("1");exit(0);}

	fac[0]=1;

	for(int i=1;i<=n*k;++i) fac[i]=1ll*fac[i-1]*i%mod;

	iac[n*k]=ginv(fac[n*k]);

	for(int i=n*k;i;--i) iac[i-1]=1ll*iac[i]*i%mod;

	int nw=1,la=0;

	f[la][0]=1;

	for(int i=1;i<=n+n;++i)

	{

		for(int j=0;j<i&&j<=n;++j)

		{

			if(!f[la][j]) continue;

			if(j<=n) ad(f[nw][j+1],1ll*f[la][j]*C(i-1+(k-2)*(j+1),k-2)%mod);

			if(j>=i-j) ad(f[nw][j],f[la][j]);

			f[la][j]=0;

		}

		nw^=1,la^=1;

	}

	printf("%d\n",(int)(1ll*fac[n]*f[la][n]%mod));

	return 0;

}


// Faster C++ solution for the same problem (measured speedup: 3.100306402058813x):
#include <cstdio>



const int MAXN = 2000, MAXL = MAXN * MAXN, MOD = 1e9 + 7;

int n, K, fac[MAXL + 5], ifac[MAXL + 5], f[MAXN + 5][MAXN + 5];



inline void addeq ( int& a, const int b ) { if ( ( a += b ) >= MOD ) a -= MOD; }



inline int qkpow ( int a, int b ) {

	int ret = 1;

	for ( ; b; a = 1ll * a * a % MOD, b >>= 1 ) ret = 1ll * ret * ( b & 1 ? a : 1 ) % MOD;

	return ret;

}



inline void init ( const int n ) {

	fac[0] = 1;

	for ( int i = 1; i <= n; ++ i ) fac[i] = 1ll * i * fac[i - 1] % MOD;

	ifac[n] = qkpow ( fac[n], MOD - 2 );

	for ( int i = n - 1; ~ i; -- i ) ifac[i] = ( i + 1ll ) * ifac[i + 1] % MOD;

}



inline int C ( const int n, const int m ) {

	return n < m ? 0 : 1ll * fac[n] * ifac[m] % MOD * ifac[n - m] % MOD;

}



int main () {

	scanf ( "%d %d", &n, &K );

	if ( K == 1 ) return puts ( "1" ), 0;

	init ( n * K ), f[0][0] = 1;

	for ( int i = 1; i <= n; ++ i ) {

		for ( int j = 0; j <= i; ++ j ) {

			int& cur = f[i][j];

			if ( i ^ j ) addeq ( cur, f[i - 1][j] );

			if ( j ) addeq ( cur, 1ll * f[i][j - 1]

				* C ( n * K - i - ( j - 1 ) * ( K - 1 ) - 1, K - 2 ) % MOD );

		}

	}

	printf ( "%d\n", int ( 1ll * f[n][n] * fac[n] % MOD ) );

	return 0;

}
// Slower C++ solution:
#include<bits/stdc++.h>

#define LL long long

#define db double



using namespace std;

const int N=2000+10,mod=1e9+7;

int rd()

{

    int x=0,w=1;char ch=0;

    while(ch<'0'||ch>'9'){if(ch=='-') w=-1;ch=getchar();}

    while(ch>='0'&&ch<='9'){x=x*10+(ch^48);ch=getchar();}

    return x*w;

}

void ad(int &x,int y){x+=y,x-=x>=mod?mod:0;}

int fpow(int a,int b){int an=1;while(b){if(b&1) an=1ll*an*a%mod;a=1ll*a*a%mod,b>>=1;}return an;}

int ginv(int a){return fpow(a,mod-2);}

int n,k,fac[N*N],iac[N*N],f[2][N];

int C(int a,int b){return b<0||a<b?0:1ll*fac[a]*iac[b]%mod*iac[a-b]%mod;}



int main()

{

	n=rd(),k=rd();

	if(k==1){puts("1");exit(0);}

	fac[0]=1;

	for(int i=1;i<=n*k;++i) fac[i]=1ll*fac[i-1]*i%mod;

	iac[n*k]=ginv(fac[n*k]);

	for(int i=n*k;i;--i) iac[i-1]=1ll*iac[i]*i%mod;

	int nw=1,la=0;

	f[la][0]=1;

	for(int i=1;i<=n+n;++i)

	{

		for(int j=0;j<i&&j<=n;++j)

		{

			if(!f[la][j]) continue;

			if(j<=n) ad(f[nw][j+1],1ll*f[la][j]*C(i-1+(k-2)*(j+1),k-2)%mod);

			if(j>=i-j) ad(f[nw][j],f[la][j]);

			f[la][j]=0;

		}

		nw^=1,la^=1;

	}

	printf("%d\n",(int)(1ll*fac[n]*f[la][n]%mod));

	return 0;

}


// Faster C++ solution for the same problem (measured speedup: 3.460269508674631x):
#include <stdio.h>

#include <algorithm>

#include <memory.h>



typedef long long ll;



const ll N = 2e3 + 5;

const ll P = 1e9 + 7;



ll n, k;

ll fac[N * N];

ll f[N][N];



ll read()

{

    ll x = 0, f = 1;

    char ch = getchar();

    while ('0' > ch or ch > '9')

        f = ch == '-' ? -1 : 1, ch = getchar();

    while ('0' <= ch and ch <= '9')

        x = x * 10 + ch - 48, ch = getchar();

    return x * f;

}



ll pow(ll x, ll k)

{

    ll res = 1;

    for (x %= P; k; k >>= 1, x = x * x % P)

        if (k & 1)

            res = res * x % P;

    return res;

}



ll C(ll n, ll m) { return ((fac[n] * pow(fac[m], P - 2)) % P * pow(fac[n - m], P - 2) % P); }



signed main()

{

    n = read(), k = read();

    if (k == 1)

    {

        puts("1");

        return 0;

    }

    fac[0] = 1;

    for (ll i = 1; i <= n * k; i++)

        fac[i] = fac[i - 1] * i % P;

    for (ll i = 0; i <= n; i++)

        f[i][0] = 1;

    for (ll i = 1; i <= n; i++)

        for (ll j = 1; j <= i; j++)

            f[i][j] = f[i - 1][j] +

                      f[i][j - 1] * (n - j + 1) % P *

                          C(n * k - i - (j - 1) * (k - 1) - 1, k - 2) % P;

    printf("%lld", f[n][n]);

    return 0;

}
// Slower C++ solution:
#include <bits/stdc++.h>

#define ll long long

const int md=1e9+7;

const int maxm=4001000;

const int maxn=2001;

int read(){

	int x=0,flag=1;char ch=getchar();

	while(!isdigit(ch)&&ch!='-') ch=getchar();

	if (ch=='-') flag=-1,ch=getchar();

	while(isdigit(ch)) x=(x<<3)+(x<<1)+(ch-'0'),ch=getchar();

	return x*flag;

}

ll fac[maxm],inv[maxm];

ll ksm(ll a,ll b){

	ll res=1;

	while(b){

		if (b&1) res=res*a%md;

		a=a*a%md;b>>=1;

	}

	return res;

}

void init(int n){

	fac[0]=1;

	for (int i=1;i<=n;++i)

		fac[i]=fac[i-1]*i%md;

	inv[n]=ksm(fac[n],md-2);

	for (int i=n;i;--i)

		inv[i-1]=inv[i]*i%md;

}

ll c(int n,int m){

	return fac[n]*inv[m]%md*inv[n-m]%md;

}

int n,k,f[maxn][maxn];

int main(){

	n=read(),k=read();

	if (k==1) return puts("1"),0;

	init(n*k);

	f[0][0]=1;

	for (int i=1;i<=n;++i){

		for (int j=0;j<=i;++j){

			f[i][j]=f[i-1][j];

			if (!j) continue;

			(f[i][j]+=1ll*f[i][j-1]*(n-j+1)%md*

			c(n-i+(n-j+1)*(k-1)-1,k-2)%md)%=md;

		}

	}

	printf("%d\n",f[n][n]);

}

// Faster C++ solution for the same problem (measured speedup: 3.7716707826126425x):
#include <algorithm>

#include <cmath>

#include <cstdio>

#include <cstring>



const int N = 2e3 + 32, M = 5e6 + 65, P = 1e9 + 7;



int pw(int x, int y) {

	int r = 1;

	for (; y; y >>= 1, x = 1ll * x * x % P)

		if (y & 1) r = 1ll * r * x % P;

	return r;

}



int fac[M], ifac[M];

int c(int n, int m) { return 1ll * n[fac] * m[ifac] % P * (n - m)[ifac] % P; }



int n, k, dp[N][N];

int main() {

	scanf("%d%d", &n, &k);

	if (k == 1) return puts("1"), 0;

	0 [fac] = 0 [ifac] = 1;

	for (int i = 1; i <= n * k; i++) i[fac] = 1ll * (i - 1)[fac] * i % P;

	(n * k)[ifac] = pw((n * k)[fac], P - 2);

	for (int i = n * k - 1; i >= 1; i--) i[ifac] = 1ll * (i + 1)[ifac] * (i + 1) % P;

	for (int i = 0; i <= n; i++)

		for (int j = 0; j <= i; j++)

			if (i || j)

				dp[i][j] = (dp[i - 1][j] +

							(n - j + 1ll) * c(n * k - i - (j - 1) * (k - 1) - 1, k - 2) %

								P * dp[i][j - 1]) %

						   P;

			else

				dp[0][0] = 1;

	printf("%d", dp[n][n]);

}
// Slower C++ solution:
#include<iostream>

#include<cstdio>

#include<cmath>

#include<cstring>

#include<algorithm>

#include<queue>

#include<vector>

#define pb push_back

#define mp make_pair

#define fi first

#define se second

using namespace std;



typedef long long LL;



inline int read()

{

	char c=getchar();int num=0,f=1;

	for(;!isdigit(c);c=getchar())

		f=c=='-'?-1:f;

	for(;isdigit(c);c=getchar())

		num=num*10+c-'0';

	return num*f;

}



const int N=2e3+5;

const int M=N*N;

const int mod=1e9+7;



inline void add(int &x,int y){(x+=y)>=mod?x-=mod:0;}



int ksm(int x,int k)

{

	int res=1;

	for(;k;k>>=1,x=1ll*x*x%mod)

		if(k&1) res=1ll*res*x%mod;

	return res;

}



int n,k;

int f[N][N],fac[M],ifac[M];



int C(int n,int m){return 1ll*fac[n]*ifac[m]%mod*ifac[n-m]%mod;}



int main()

{

	n=read(),k=read();

	if(k==1)

	{

		cout<<1;

		return 0;

	}

	fac[0]=1;

	for(int i=1;i<=n*k;++i) fac[i]=1ll*fac[i-1]*i%mod;

	ifac[n*k]=ksm(fac[n*k],mod-2);

	for(int i=n*k-1;~i;--i) ifac[i]=1ll*ifac[i+1]*(i+1)%mod;

	f[0][0]=1;

	for(int i=0;i<=n;++i)

	{

		for(int j=0;j<=i;++j)

		{

			if(i) add(f[i][j],f[i-1][j]);

			if(j) add(f[i][j],1ll*f[i][j-1]*C(n-i+(n-j+1)*(k-1)-1,k-2)%mod);

		}

	}

	cout<<1ll*f[n][n]*fac[n]%mod;

	return 0;

}

// Faster C++ solution for the same problem (measured speedup: 3.063178656302681x):
#include <algorithm>

#include <cmath>

#include <cstdio>

#include <cstring>



const int N = 2e3 + 32, M = 5e6 + 65, P = 1e9 + 7;



int pw(int x, int y) {

	int r = 1;

	for (; y; y >>= 1, x = 1ll * x * x % P)

		if (y & 1) r = 1ll * r * x % P;

	return r;

}



int fac[M], ifac[M];

int c(int n, int m) { return 1ll * n[fac] * m[ifac] % P * (n - m)[ifac] % P; }



int n, k, dp[N][N];

int main() {

	scanf("%d%d", &n, &k);

	if (k == 1) return puts("1"), 0;

	0 [fac] = 0 [ifac] = 1;

	for (int i = 1; i <= n * k; i++) i[fac] = 1ll * (i - 1)[fac] * i % P;

	(n * k)[ifac] = pw((n * k)[fac], P - 2);

	for (int i = n * k - 1; i >= 1; i--) i[ifac] = 1ll * (i + 1)[ifac] * (i + 1) % P;

	for (int i = 0; i <= n; i++)

		for (int j = 0; j <= i; j++)

			if (i || j)

				dp[i][j] = (dp[i - 1][j] +

							(n - j + 1ll) * c(n * k - i - (j - 1) * (k - 1) - 1, k - 2) %

								P * dp[i][j - 1]) %

						   P;

			else

				dp[0][0] = 1;

	printf("%d", dp[n][n]);

}
// Slower C++ solution:
#include <iostream>

#include <cstdio>

using namespace std;



const int MOD(1000000007);

int n, k;

int fac[4000000], inv_fac[4000000], dp[2001];





int Power(long long a, int b)

{

	long long ret(1ll);

	

	while (b) {

		b & 1 && (ret *= a);

		ret >= MOD && (ret %= MOD);

		a *= a;

		a >= MOD && (a %= MOD);

		b >>= 1;

	}

	return ret;

}





int main()

{

	register long long lt;

	int t;

	

	scanf("%d%d", &n, &k);

	if (k == 1) {

		printf("1\n");

		return 0;

	}

	fac[0] = 1;

	t = n * k;

	for (int i = 1; i < t; ++i) {

		lt = (long long)i * fac[i - 1];

		fac[i] = lt < MOD ? lt : lt % MOD; 

	}

	inv_fac[t - 1] = Power((long long)fac[t - 1], MOD - 2);

	for (int i = t - 2; i; --i) {

		lt = (long long)(i + 1) * inv_fac[i + 1];

		inv_fac[i] = lt < MOD ? lt : lt % MOD;

	}

	inv_fac[0] = 1;

	dp[0] = 1;

	t = -2;

	for (int i = 1; i <= n; ++i) {

		t += k - 1;

		for (int j = 0; j <= i; ++j) {

			++t;

			lt = (long long)fac[t] * inv_fac[t - k + 2];

			lt >= MOD && (lt %= MOD);

			lt *= (long long)inv_fac[k - 2];

			lt >= MOD && (lt %= MOD);

			lt *= (long long)dp[j];

			j && (lt += dp[j - 1]);

			dp[j] = lt < MOD ? lt : lt % MOD;

		}

		t -= i + 1;

	}

	lt = (long long)dp[n] * fac[n] % MOD;

	printf("%lld\n", lt);

	return 0;

}




// Faster C++ solution for the same problem (measured speedup: 2.4398114321688347x):
#include <algorithm>

#include <cmath>

#include <cstdio>

#include <cstring>



const int N = 2e3 + 32, M = 5e6 + 65, P = 1e9 + 7;



int pw(int x, int y) {

	int r = 1;

	for (; y; y >>= 1, x = 1ll * x * x % P)

		if (y & 1) r = 1ll * r * x % P;

	return r;

}



int fac[M], ifac[M];

int c(int n, int m) { return 1ll * n[fac] * m[ifac] % P * (n - m)[ifac] % P; }



int n, k, dp[N][N];

int main() {

	scanf("%d%d", &n, &k);

	if (k == 1) return puts("1"), 0;

	0 [fac] = 0 [ifac] = 1;

	for (int i = 1; i <= n * k; i++) i[fac] = 1ll * (i - 1)[fac] * i % P;

	(n * k)[ifac] = pw((n * k)[fac], P - 2);

	for (int i = n * k - 1; i >= 1; i--) i[ifac] = 1ll * (i + 1)[ifac] * (i + 1) % P;

	for (int i = 0; i <= n; i++)

		for (int j = 0; j <= i; j++)

			if (i || j)

				dp[i][j] = (dp[i - 1][j] +

							(n - j + 1ll) * c(n * k - i - (j - 1) * (k - 1) - 1, k - 2) %

								P * dp[i][j - 1]) %

						   P;

			else

				dp[0][0] = 1;

	printf("%d", dp[n][n]);

}
// Slower C++ solution:
#include <bits/stdc++.h>

#define ll long long

using namespace std;

const ll P=1e9+7,MAXN=4e6+10;

ll n,k,fac[MAXN],inv[MAXN],dp[2010][2010];

ll qpow (ll a,ll b) {

	ll res=1;

	while (b) {

		if (b&1) {

			res=(res*a)%P;

		}

		a=(a*a)%P;

		b>>=1;

	}

	return res;

}

ll c (ll n,ll m) {

	return (((fac[n]*inv[m])%P)*inv[n-m])%P;

}

int main () {

	scanf("%lld%lld",&n,&k);

	if (k==1) {

		printf("%d\n",1);

		return 0;

	}

	fac[0]=inv[0]=1;

	for (ll i=1;i<=n*k;i++) {

		fac[i]=(i*fac[i-1])%P;

	}

	inv[n*k]=qpow(fac[n*k],P-2);

	for (ll i=n*k-1;i>=1;i--) {

		inv[i]=(inv[i+1]*(i+1))%P;

	}

	for (int i=1;i<=n;i++) {

		dp[i][0]=1;

	}

	for (int i=1;i<=n;i++) {

		for (int j=1;j<=i;j++) {

			dp[i][j]=(dp[i-1][j]+(((dp[i][j-1]*(n-j+1))%P)*c(n*k-i-1-(j-1)*(k-1),k-2))%P)%P;

		}

	}

	printf("%lld\n",dp[n][n]);

	return 0;

}

// Faster C++ solution for the same problem (measured speedup: 3.272107596412161x):
#include <algorithm>

#include <cmath>

#include <cstdio>

#include <cstring>



const int N = 2e3 + 32, M = 5e6 + 65, P = 1e9 + 7;



int pw(int x, int y) {

	int r = 1;

	for (; y; y >>= 1, x = 1ll * x * x % P)

		if (y & 1) r = 1ll * r * x % P;

	return r;

}



int fac[M], ifac[M];

int c(int n, int m) { return 1ll * n[fac] * m[ifac] % P * (n - m)[ifac] % P; }



int n, k, dp[N][N];

int main() {

	scanf("%d%d", &n, &k);

	if (k == 1) return puts("1"), 0;

	0 [fac] = 0 [ifac] = 1;

	for (int i = 1; i <= n * k; i++) i[fac] = 1ll * (i - 1)[fac] * i % P;

	(n * k)[ifac] = pw((n * k)[fac], P - 2);

	for (int i = n * k - 1; i >= 1; i--) i[ifac] = 1ll * (i + 1)[ifac] * (i + 1) % P;

	for (int i = 0; i <= n; i++)

		for (int j = 0; j <= i; j++)

			if (i || j)

				dp[i][j] = (dp[i - 1][j] +

							(n - j + 1ll) * c(n * k - i - (j - 1) * (k - 1) - 1, k - 2) %

								P * dp[i][j - 1]) %

						   P;

			else

				dp[0][0] = 1;

	printf("%d", dp[n][n]);

}