#include <bits/stdc++.h>
#define mp make_pair
#define eb emplace_back
#define fi first
#define se second
using namespace std;
using cd = complex <double>;
 
typedef pair <int, int> pii;
const int N = 3e3 + 5;
const long long INF = 1e18;
const int mod = 1e9 + 7;//786433;//998244353;
const double Pi = acos(-1);
const int p = 510200;
 
void Fastio()
{
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
}

int n, m;
int Fact[200005];
map <int, int> M;

int BinPow(int x, int n)
{
	if(n == 0)
	{
		return 1;
	}
	int temp = BinPow(x, n >> 1);
	if(n & 1)
	{
		return 1ll * temp * temp % mod * x % mod;
	}
	else
	{
		return 1ll * temp * temp % mod;
	}
}

int C(int k, int n)
{
	return 1ll * Fact[n] * BinPow(Fact[k], mod - 2) % mod * BinPow(Fact[n - k], mod - 2) % mod;
}

signed main()
{
//	Fastio();
	cin >> n >> m;
	Fact[0] = 1;
	for(int i = 1; i <= 2e5; i++)
	{	
		Fact[i] = 1ll * Fact[i - 1] * i % mod;
	}
	for(int i = 2; i <= sqrt(m); i++)
	{
		while(m % i == 0)
		{
			M[i]++;
			m /= i;
		}
	}
	if(m > 1)
	{
		M[m]++;
	}
	int ans = 1;
	for(auto x : M)
	{
		ans = 1ll * ans * C(n - 1, x.se + n - 1) % mod;
	}
	cout << ans;
}
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < n; i++)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pi;
typedef pair<ll, ll> pl;
const double EPS = 1e-9;
const ll MOD = 1000000007;
const int inf = 1 << 30;
const ll linf = 1LL << 60;
const double PI = 3.14159265358979323846;

#define SIZE 4000001

ll kai[SIZE];
ll mokai[SIZE];

ll mod_pow (ll x, ll y) {
    ll ret = 1;
    while (y) {
        if (y&1) ret = ret*x%MOD;
        x = x*x%MOD;
        y /= 2;
    }
    return ret;
}

void init () {
    kai[0] = 1;
    for (int i = 1; i < SIZE; i++) kai[i] = kai[i-1]*i%MOD;
    for (int i = 0; i < SIZE; i++) mokai[i] = mod_pow(kai[i],MOD-2);
}

ll conb (ll x, ll y) {
    ll z = x-y;
    ll ret = kai[x]*mokai[y]%MOD;
    ret = ret*mokai[z]%MOD;
    return ret;
}

ll n, k;
ll dp[2001][2001];

inline ll mmul (ll x, ll y) {
    return x*y%MOD;
}

int main() {
    cin >> n >> k;
    init();
    if (k == 1) {
        cout << 1 << endl;
        return 0;
    }
    dp[0][0] = 1;
    for (ll i = 1; i <= n; i++) {
        dp[i][0] = mmul(dp[i-1][0], conb(i*(k-1)-1,k-2));
    }
    for (ll j = 1; j <= n; j++) {
        for (ll i = j; i <= n; i++) {
            if (i == j) {
                dp[i][j] = dp[i][j-1];
            } else {
                dp[i][j] = (mmul(dp[i-1][j], conb(i*k-(i-j)-1, k-2)) + dp[i][j-1]) % MOD;
            }
        }
    }
    cout << (dp[n][n] * kai[n]) % MOD;
}
