#P1555. Bash Plays with Functions

Bash Plays with Functions

描述

Bash got tired on his journey to become the greatest Pokémon master. So he decides to take a break and play with functions.

Bash defines a function f0(n)f_0(n), which denotes the number of ways of factoring nn into two factors pp and qq such that gcd(p,q)=1\gcd(p, q) = 1. In other words, f0(n)f_0(n) is the number of ordered pairs of positive integers (p,q)(p, q) such that pq=np \cdot q = n and gcd(p,q)=1\gcd(p, q) = 1.

But Bash felt that it was too easy to calculate this function. So he defined a series of functions, where fr+1f_{r+1} is defined as:

$$f_{r+1}(n) = \sum_{u \cdot v = n} f_r(u) \cdot f_r(v)$$

Where (u,v)(u, v) is any ordered pair of positive integers, they need not to be co-prime.

Now Bash wants to know the value of fr(n)f_r(n) for different rr and nn. Since the value could be huge, he would like to know the value modulo 109+710^9 + 7. Help him!

题意

定义函数f0(n)f_0(n)为满足pq=npq=ngcd(p,q)=1gcd(p,q)=1的有序对(p,q)(p,q)的个 数。

定义递推关系: fr+1(n)=pq=nfr(p)+fr(q)2f_r+1(n)=\sum _{pq=n}\frac {f_r(p)+f_r(q)}{2}

给定q次询问,每次询问fr(n)mod(109+7)f_r(n)mod (10^9+7)的值。

数据范围:1n,r,q1061≤n,r,q≤10^6

输入

The first line contains an integer qq (1q1061 \leq q \leq 10^6) — the number of values Bash wants to know.

Each of the next qq lines contain two integers rr and nn (0r1060 \leq r \leq 10^6, 1n1061 \leq n \leq 10^6), which denote Bash wants to know the value fr(n)f_r(n).

输出

Print qq integers. For each pair of rr and nn given, print fr(n)f_r(n) modulo 109+710^9 + 7 on a separate line.

样例

5
0 30
1 25
3 65
2 5
4 48
8
5
25
4
630