Problem: Bash got tired on his journey to become the greatest Pokemon master. So he decides to take a break and play with functions.

Bash defines a function f0(n), which denotes the number of ways of factoring n into two factors p and q such that gcd(p, q) = 1. In other words, f0(n) is the number of ordered pairs of positive integers (p, q) such that p·q = n and 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 + 1 is defined as:

<image>

Where (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) for different r and n. Since the value could be huge, he would like to know the value modulo 109 + 7. Help him!

Input

The first line contains an integer q (1 ≤ q ≤ 106) — the number of values Bash wants to know.

Each of the next q lines contain two integers r and n (0 ≤ r ≤ 106, 1 ≤ n ≤ 106), which denote Bash wants to know the value fr(n).

Output

Print q integers. For each pair of r and n given, print fr(n) modulo 109 + 7 on a separate line.

Example

Input

5
0 30
1 25
3 65
2 5
4 48


Output

8
5
25
4
630

Solution (in CPP):

Solution:
#include <bits/stdc++.h>
using namespace std;
inline int read() {
  int s = 0, t = 1;
  char ch = getchar();
  while (ch < '0' || ch > '9') {
    if (ch == '-') t = -1;
    ch = getchar();
  }
  while (ch >= '0' && ch <= '9')
    s = (s << 3) + (s << 1) + (ch ^ 48), ch = getchar();
  return s * t;
}
const int P = 1e9 + 7;
const int N = 2e6 + 5;
bool vis[N];
int tot, a[30], b[30];
int fac[N], inv[N], p[N / 10], lp[N];
int ksm(int x, int k) {
  int res = 1;
  while (k) {
    if (k & 1) res = 1ll * res * x % P;
    x = 1ll * x * x % P, k >>= 1;
  }
  return res;
}
void Pre(int n) {
  fac[0] = 1;
  for (int i = 1; i <= n; i++) fac[i] = 1ll * fac[i - 1] * i % P;
  inv[n] = ksm(fac[n], P - 2);
  for (int i = n; i >= 1; i--) inv[i - 1] = 1ll * inv[i] * i % P;
  for (int i = 2; i <= n; i++) {
    if (!vis[i]) p[++tot] = i, lp[i] = i;
    for (int j = 1; j <= tot && i * p[j] <= n; j++) {
      vis[i * p[j]] = 1, lp[i * p[j]] = p[j];
      if (i % p[j] == 0) break;
    }
  }
}
int C(int n, int m) {
  return (n < m || m < 0) ? 0 : 1ll * fac[n] * inv[m] % P * inv[n - m] % P;
}
int Solve(int r, int n) {
  a[tot = 0] = 0;
  while (n ^ 1) {
    int t = lp[n];
    n /= t;
    if (t ^ a[tot])
      a[++tot] = t, b[tot] = 1;
    else
      b[tot]++;
  }
  if (r == 0) return ksm(2, tot);
  int res = 1;
  for (int i = 1; i <= tot; i++) {
    int l = b[i], tmp = C(r + l - 1, r - 1);
    for (int j = 1; j <= l; j++)
      tmp = (tmp + 2ll * C(r + l - j - 1, r - 1) % P) % P;
    res = 1ll * res * tmp % P;
  }
  return res;
}
int main() {
  Pre(2e6);
  for (int T = read(); T; T--) {
    int r = read(), n = read();
    printf("%d\n", Solve(r, n));
  }
  return 0;
}