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 Haskell (GHC 7.10.3) (judge verdict: Accepted)

import Data.List

mPrime = 10^9 + 7

mAdd :: Int -> Int -> Int
mAdd x y = (x + y) `mod` mPrime

mSub :: Int -> Int -> Int
mSub x y = (mPrime + x - y) `mod` mPrime

mMul :: Int -> Int -> Int
mMul x y = (x * y) `mod` mPrime

mInv :: Int -> Int
mInv x = let (_, a, _) = eGCD x mPrime in if a < 0 then a + mPrime else a

eGCD :: Int -> Int -> (Int,Int,Int)
eGCD 0 b = (b, 0, 1)
eGCD a b = let (g, s, t) = eGCD (b `mod` a) a
           in (g, t - (b `div` a) * s, s)

mLstMul = foldl1' mMul

solve :: Int -> Int -> Int
solve n 1 = 1
solve n m = mLstMul $ map f (primeFact m)
  where f k = combi (n+k-1) k

sieve :: [Int]
sieve = 2 : sieve_sub [2] [3..]

sieve_sub :: [Int] -> [Int] -> [Int]
sieve_sub (n:yet) cand =
  let
    (cnfmd, rem) = span (< n*n) cand
    newcand = filter (\i -> i `mod` n /= 0) rem
  in cnfmd ++ sieve_sub (yet ++ cnfmd) newcand

primes = takeWhile (< 32000) sieve

primeFact :: Int -> [Int]
primeFact x = pf0 x sieve

pf0 1 _ = []
pf0 x [] = [1]
pf0 x (p:sieves)
  | p*p > x = [1]
  | kk > 0 = kk : pf0 yy sieves
  | otherwise = pf0 x sieves
  where (kk, yy) = pf1 p x
        pf1 p x | mm > 0 = (0, x)
                | otherwise = let (kk', yy') = pf1 p dd in (kk'+1, yy')
          where (dd,mm) = divMod x p

combi n0 r0 | r0 > (n0 - r0) = combi n0 (n0 - r0)
combi n0 0 = 1
combi n0 r0 = (mLstMul [n0,n0-1..(n0-r0+1)]) `mMul` (mInv (mLstMul [r0,r0-1..1]))

main = do
  cont <- getContents
  let [n,m] = map read $ words cont
      ans = solve n m
  putStrLn $ show $ ans