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;
const int mod = 1e9 + 7, N = 1e6 + 5, LN = 25;
inline int scan() {
  int res = 0;
  char c = getchar();
  while (c < '0' or c > '9') c = getchar();
  while (c >= '0' and c <= '9') {
    res = (res << 1) + (res << 3) + (c - '0');
    c = getchar();
  }
  return res;
}
inline int add(int a, int b) {
  int res = a + b;
  if (res >= mod) res -= mod;
  return res;
}
inline int mult(int a, int b) {
  long long res = a * 1LL * b;
  return res % mod;
}
int big[N];
void pre() {
  for (int i = 0; i < N; i++) big[i] = i;
  for (int i = 2; i < N; i++) {
    if (big[i] != i) continue;
    for (int j = i; j < N; j += i) {
      big[j] = i;
    }
  }
}
int q;
int dp[N][LN];
int sum[N][LN];
int main() {
  dp[0][0] = 1;
  sum[0][0] = 1;
  pre();
  for (int i = 0; i < N; i++) {
    for (int j = 0; j < LN; j++) {
      if (i == 0 and j == 0) continue;
      dp[i][j] = i != 0 ? sum[i - 1][j] : 2;
      sum[i][j] = add(j != 0 ? sum[i][j - 1] : 0, dp[i][j]);
    }
  }
  q = scan();
  while (q--) {
    int r = scan(), n = scan();
    int ans = 1;
    while (n != 1) {
      int cnt = 0;
      int which = big[n];
      while (n % which == 0) {
        n /= which;
        cnt++;
      }
      ans = mult(ans, dp[r][cnt]);
    }
    printf("%d\n", ans);
  }
}