<p>You are given a 2D integer array, <code>queries</code>. For each <code>queries[i]</code>, where <code>queries[i] = [n<sub>i</sub>, k<sub>i</sub>]</code>, find the number of different ways you can place positive integers into an array of size <code>n<sub>i</sub></code> such that the product of the integers is <code>k<sub>i</sub></code>. As the number of ways may be too large, the answer to the <code>i<sup>th</sup></code> query is the number of ways <strong>modulo</strong> <code>10<sup>9</sup> + 7</code>.</p>

<p>Return <em>an integer array </em><code>answer</code><em> where </em><code>answer.length == queries.length</code><em>, and </em><code>answer[i]</code><em> is the answer to the </em><code>i<sup>th</sup></code><em> query.</em></p>

<p>&nbsp;</p>
<p><strong class="example">Example 1:</strong></p>

<pre>
<strong>Input:</strong> queries = [[2,6],[5,1],[73,660]]
<strong>Output:</strong> [4,1,50734910]
<strong>Explanation:</strong>&nbsp;Each query is independent.
[2,6]: There are 4 ways to fill an array of size 2 that multiply to 6: [1,6], [2,3], [3,2], [6,1].
[5,1]: There is 1 way to fill an array of size 5 that multiply to 1: [1,1,1,1,1].
[73,660]: There are 1050734917 ways to fill an array of size 73 that multiply to 660. 1050734917 modulo 10<sup>9</sup> + 7 = 50734910.
</pre>

<p><strong class="example">Example 2:</strong></p>

<pre>
<strong>Input:</strong> queries = [[1,1],[2,2],[3,3],[4,4],[5,5]]
<strong>Output:</strong> [1,2,3,10,5]
</pre>

<p>&nbsp;</p>
<p><strong>Constraints:</strong></p>

<ul>
	<li><code>1 &lt;= queries.length &lt;= 10<sup>4</sup> </code></li>
	<li><code>1 &lt;= n<sub>i</sub>, k<sub>i</sub> &lt;= 10<sup>4</sup></code></li>
</ul>

class Solution {
public:
    long long binpow(long long a, long long b, long long M){
        long long res=1;
        while(b){
            if(b&1){
                res*=a;
                res%=M;
            }
            a*=a;
            a%=M;
            b/=2;
        }
        return res;
    }
    
    void solve(vector<long long>&fac,vector<long long>&spf){
        fac[0]=fac[1]=1;
        const int M=1e9+7;
        for(int i=2;i<=2e4;i++){
            fac[i]=fac[i-1]*i;
            fac[i]%=M;
        }

        for(int i=1;i<=2e4;i++){
            spf[i]=i;
        }

        for(int i=2;i*i<=2e4;i++){
            if(spf[i]==i){
                for(int j=i*i;j<=2e4;j+=i){
                    spf[j]=min(spf[j],spf[i]);
                }
            }
        }

    }

    long long ncr(long long n, long long r, vector<long long>&fac){
        long long ans=fac[n];
        const int M=1e9+7;

        ans*=binpow(fac[n-r],M-2,M);
        ans%=M;
        ans*=binpow(fac[r],M-2,M);
        ans%=M;
        return ans;
    }
    vector<int> waysToFillArray(vector<vector<int>>& queries) {
        vector<int>ans;
        vector<long long>fac(2e4+5,0),spf(2e4+5,0);
        solve(fac,spf);
        const int M=1e9+7;
        for(auto x:queries){
            map<int,int>cnt;
            long long val=x[1];
            while(val!=1){
                cnt[spf[val]]++;
                val/=spf[val];
            }
            vector<int>ran;
            for(auto x:cnt){
                ran.push_back(x.second);
            }
            long long sum=1;
            for(auto y:ran){
                sum*=ncr(x[0]+y-1,y,fac);
                sum%=M;
            }
            ans.push_back(sum);
        }

        return ans;
    }
};
73000