<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:
    const static int N = 1e4 + 14;
    const int mod = 1e9 + 7;
    int spf[N], comb[N][14];;

    void precomputeSPF(){
        for (int i=0; i<N; i++){
            spf[i] = i;
        }
        for (int i=2; i<N; i++){
            if (spf[i] == i){
                for (int j=2*i; j<N; j+=i){
                    if (spf[j] == j) spf[j] = i;
                }
            }
        }
    }

int binExp(int long long a,int long long b,int long long mod){
 int long long res=1;
 while(b>0){
 if(b&1){
 res=(res%mod*a%mod)%mod;
 }
 a=(a%mod*a%mod)%mod;
 b>>=1;
 }
 return res;
 }
int inverse_modulu(int long long a,int long long mod){
 return binExp(a,mod-2,mod);
 }
    int long long ncr(int n,int r,vector<int long long>&fac){
    if(r>n) return 0;
    int long long nm=(fac[n]%mod*inverse_modulu((fac[r]%mod*fac[n-r]%mod)%mod,mod)%mod)%mod;
    return nm;
}



    vector<int> waysToFillArray(vector<vector<int>>& que) {
        int n, k, r, fac;
        vector<int> ans(que.size(),1);
        precomputeSPF();

        vector<int long long>fact(1e5+1,0);
        fact[0]=1,fact[1]=1;
        for(int i=2;i<1e5;i++){
            fact[i]=(fact[i-1]%mod*i%mod)%mod;
        }

        for (int i=0; i<que.size(); i++){
            n = que[i][0];
            k = que[i][1];
            while (k != 1){
                fac = spf[k];
                r = 0;
                while (k % fac == 0){
                    k /= fac;
                    r += 1;
                }
                //   **|*|**|*
                //   Choose r positions for * or n positions for |
                //   Cnt = (n+r)C(r)
                ans[i] = (long long)ans[i] * ncr(n-1+r,n-1,fact) % mod;
            }
        }
        return ans;
    }
};
91300