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 Scala (2.11.7) (judge verdict: Runtime Error)

import scala.io.StdIn.readLine

object Main {
  def main(args: Array[String]): Unit ={
    D.answer()
  }
}

object D{
  def multi(a:Long, b:Long):Long = a * b
  def divide(a: Long, b: Long):Long = a / b
  def remain(a: Long, b: Long):Long = a % b

  def primes(max:Int): List[Int] = {
    (1 to (max / 6).toInt + 1).foldLeft(List(2,3)){(acc,c) => {
      val a = c*6-1
      val b = c*6+1
      val sq = acc.takeWhile(a=> a <= math.sqrt(b).toInt+1)
      val k=if(sq.foldLeft(true){(acc, c) => if(acc && remain(a, c) != 0) true else false}) List(a) else List()
      val v=if(sq.foldLeft(true){(acc, c) => if(acc && remain(b, c) != 0) true else false}) List(b) else List()
      acc++k++v
    }}
  }
  def multiper(n:Int, m:Long, c:Int):(Int, Long) = if(m % n == 0) multiper(n, m/n, c+1) else (c,m)

  def fac(l:List[Int], m:Long): List[Int] = {
    multiper(l.head, m, 0) match {
      case (0,1) => List()
      case (x,1) => List(x)
      case (0,y) => fac(l.tail, y)
      case (x,y) => List(x) ::: fac(l.tail, y)
    }
  }
  def invmod(p:Long, g:Long) = {
    def euclidean(px:Long, py:Long, pgcd: Long, x:Long, y:Long, gcd: Long):Long = {
      pgcd % gcd match {
        case 0 => (x + g) % g
        case m => {
          val d = pgcd / gcd
          euclidean(x,y,gcd, px-(d*x), py-(d*y), m)
        }
      }
    }
    euclidean(1,0,p,0,1,g)
  }
  def comb(n:Long, k:Long, p:Long):Long = {
    (1 to k.toInt).foldLeft(1.toLong)((acc,c)=> remain((multi(remain(multi(acc,(n-c+1)), p), invmod(c,p))), p))
  }
  def input[A](change: String => A) = readLine.split(" ").map(change(_))
  def answer(): Unit ={
    val p = math.pow(10,9).toInt + 7
    val a = input((a=>a.toLong))
    val n = a(0)
    val m = a(1)
    val f = fac(primes(math.sqrt(p).toInt), m)
    val ans = f.foldLeft(1.toLong)((acc,c)=>(multi(acc, comb(c+n-1, c, p))) % p)
    println(ans)
  }
}