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 Rust (1.15.1) (judge verdict: Runtime Error)

/// Thank you tanakh!!!
/// https://qiita.com/tanakh/items/0ba42c7ca36cd29d0ac8
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let mut s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

macro_rules! input_inner {
    ($iter:expr) => {};
    ($iter:expr, ) => {};

    ($iter:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($iter, $t);
        input_inner!{$iter $($r)*}
    };
}

macro_rules! read_value {
    ($iter:expr, ( $($t:tt),* )) => {
        ( $(read_value!($iter, $t)),* )
    };

    ($iter:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>()
    };

    ($iter:expr, chars) => {
        read_value!($iter, String).chars().collect::<Vec<char>>()
    };

    ($iter:expr, usize1) => {
        read_value!($iter, usize) - 1
    };

    ($iter:expr, $t:ty) => {
        $iter.next().unwrap().parse::<$t>().expect("Parse error")
    };
}

use std::cmp;
use std::collections::{BTreeMap, VecDeque};

const MOD: usize = 1e9 as usize + 7;

fn main() {
    input!(n: usize, m: usize);

    let mut divisors = vec![];
    {
        let mut primes = vec![];
        let mut is_prime = vec![true; 1e5 as usize];
        is_prime[0] = false;
        is_prime[1] = false;
        for i in 2..is_prime.len() {
            if is_prime[i] {
                primes.push(i);
                let mut cur = i * 2;
                while cur < is_prime.len() {
                    is_prime[cur] = false;
                    cur += i;
                }
            }
        }
        let mut m = m;
        for &p in primes.iter() {
            if m % p == 0 {
                let mut count = 0;
                while m % p == 0 {
                    m /= p;
                    count += 1;
                }
                divisors.push((p, count));
            }
            if m == 1 {
                break;
            }
        }
    }

    let mut results = vec![];
    dfs(1, 0, &mut results, &divisors);
    let k = results.len();
    results.sort();

    let mut map = BTreeMap::new();
    for i in 0..k {
        map.insert(results[i], i);
    }

    assert_eq!(1, results[0]);
    assert_eq!(m, results[k - 1]);

    let mut next = vec![vec![]; k];
    for i in 0..k {
        for j in 0..k {
            if results[i] % results[j] == 0 {
                let next_k = *map.get(&(results[i] / results[j])).unwrap();
                next[i].push(next_k);
            }
        }
    }

    let mut dp = vec![vec![0; k]; n + 1];
    dp[0][k - 1] = 1;
    for i in 0..n {
        for k in 0..k {
            let cur = results[k];
            for &next_k in next[k].iter() {
                dp[i + 1][next_k] += dp[i][k];
                dp[i + 1][next_k] %= MOD;
            }
        }
    }

    println!("{}", dp[n][0]);
}

fn dfs(m: usize, pos: usize, results: &mut Vec<usize>, divisors: &Vec<(usize, usize)>) {
    if pos == divisors.len() {
        results.push(m);
        return;
    }
    let (p, count) = divisors[pos];
    let mut t = 1;
    for i in 0..(count + 1) {
        dfs(m * t, pos + 1, results, divisors);
        t *= p;
    }
}