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;
char CRTBUFF[30000];
struct debugger {
  static void call(const char* it) {}
  template <typename T, typename... aT>
  static void call(const char* it, T a, aT... rest) {
    string b;
    for (; *it && *it != ','; ++it)
      if (*it != ' ') b += *it;
    cerr << b << "=" << a << " ";
    call(++it, rest...);
  }
};
long long add(long long a, long long b) { return (a + b) % 1000000007; }
long long mul(long long a, long long b) { return (a * b) % 1000000007; }
bool composite[1000010 + 10];
vector<int> primes;
int dp[1000010 + 10][30];
int func(int r, int x) {
  if (r == 0) return (x ? 2 : 1);
  auto& ret = dp[r][x];
  if (ret != -1) return ret;
  ret = 0;
  for (int i = (0); i < (x + 1); i += (1)) ret = add(ret, func(r - 1, i));
  return ret;
}
void init() {
  int lim = sqrt(1000010);
  for (int i = (2); i < (lim); i += (1))
    if (!composite[i]) {
      for (int j = i * i; j <= 1000010; j += i) {
        composite[j] = true;
      }
    }
  for (int i = (2); i < (1000010); i += (1))
    if (!composite[i]) {
      primes.push_back(i);
    }
  memset(dp, 0, sizeof(dp));
  for (int j = (0); j < (30); j += (1)) dp[0][j] = (j ? 2 : 1);
  for (int i = (1); i < (1000010); i += (1))
    for (int j = (0); j < (21); j += (1)) {
      long long ret = 0;
      for (int k = (0); k < (j + 1); k += (1)) {
        ret += dp[i - 1][k];
      }
      dp[i][j] = ret % 1000000007;
    }
}
int main() {
  init();
  int TC;
  scanf("%d", &TC);
  for (int cs = (1); cs < (TC + 1); cs += (1)) {
    int r, n;
    scanf("%d%d", &r, &n);
    int ans = 1;
    for (auto p : primes) {
      if (((long long)p) * p > n) break;
      if (n % p == 0) {
        int cnt = 0;
        while (n % p == 0) n = n / p, cnt++;
        ans = mul(ans, dp[r][cnt]);
      }
    }
    if (n > 1) ans = mul(ans, dp[r][1]);
    printf("%d\n", ans);
  }
}