Problem:
Score : 400 points

Problem Statement

You are given positive integers N and M.

How many sequences a of length N consisting of positive integers satisfy a_1 \times a_2 \times ... \times a_N = M? Find the count modulo 10^9+7.

Here, two sequences a' and a'' are considered different when there exists some i such that a_i' \neq a_i''.

Constraints

All values in input are integers.

1 \leq N \leq 10^5

1 \leq M \leq 10^9

Input

Input is given from Standard Input in the following format:

N M

Output

Print the number of the sequences consisting of positive integers that satisfy the condition, modulo 10^9 + 7.

Sample Input 1

2 6

Sample Output 1

4

Four sequences satisfy the condition: \{a_1, a_2\} = \{1, 6\}, \{2, 3\}, \{3, 2\} and \{6, 1\}.

Sample Input 2

3 12

Sample Output 2

18

Sample Input 3

100000 1000000000

Sample Output 3

957870001

Solution in C++14 (GCC 5.4.1) (judge verdict: Time Limit Exceeded)

#include<bits/stdc++.h>
using namespace std;
long long n,m;
vector<long long>v,b;
map<long long,long long>mp;
long long a[1003],ans;
long long prime[11]={2,3,5,7,11,13,17,19,23,29,31},cnt[11];
map<pair<int,int>,int>mmm;
inline long long C(long long x,long long y){
	//cout<<"HEHE";
	if(y==0)return 1;
	if(mmm[make_pair(x,y)])return mmm[make_pair(x,y)];
	long long ans=1,xx[y];
	for(long long i=0;i<y;i++)xx[i]=x-i;
	for(long long i=1;i<=y;i++){
		long long tmp=i;
		for(long long xxx=0;xxx<11;xxx++)
			while(tmp%prime[xxx]==0)
				tmp/=prime[xxx],
				cnt[xxx]++;
	}
	for(long long i=0;i<y;i++)
		for(long long xxx=0;xxx<11;xxx++)
			while(xx[i]%prime[xxx]==0&&cnt[xxx])
				cnt[xxx]--,
				xx[i]/=prime[xxx];
	for(long long i=0;i<y;i++)ans=(ans*xx[i])%1000000007;
	mmm[make_pair(x,y)]=ans;
	return ans;
}
inline void dfs(long long x,long long y,long long z){
	if(x==1){
		for(long long i=0;i<b.size();i++)a[mp[b[i]]]++;
		long long cnt=n,ans2=1;
		for(long long i=0;i<v.size();i++)
			ans2=ans2*C(cnt,a[i])%1000000007,
			cnt-=a[i],
			a[i]=0;
		ans=(ans+ans2)%1000000007;
		return;
	}
	if(y==n)return;
	for(long long i=0;i<z&&v[i]<=x;i++)
		if(x%v[i]==0)
			b.push_back(v[i]),
			dfs(x/v[i],y+1,i+1),
			b.pop_back();
}
int main(){
	cin>>n>>m;
	for(long long i=2;i<=sqrt(m);i++)
		if(!(m%i))
			if(double(i)!=double(sqrt(m)))
				v.push_back(m/i),
				v.push_back(i);
			else
				v.push_back(i);
	sort(v.begin(),v.end());
	v.push_back(m);
	for(long long i=0;i<v.size();i++)mp[v[i]]=i;
	dfs(m,0,v.size());
	cout<<ans;
}