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;
template <typename T>
void _R(T &x) {
  cin >> x;
}
void _R(int &x) { scanf("%d", &x); }
void _R(long long &x) { scanf("%" PRId64, &x); }
void _R(double &x) { scanf("%lf", &x); }
void _R(char &x) { scanf(" %c", &x); }
void _R(char *x) { scanf("%s", x); }
void R() {}
template <typename T, typename... U>
void R(T &head, U &...tail) {
  _R(head);
  R(tail...);
}
template <typename T>
void _W(const T &x) {
  cout << x;
}
void _W(const int &x) { printf("%d", x); }
template <typename T>
void _W(const vector<T> &x) {
  for (auto i = x.cbegin(); i != x.cend(); i++) {
    if (i != x.cbegin()) putchar(' ');
    _W(*i);
  }
}
void W() {}
template <typename T, typename... U>
void W(const T &head, const U &...tail) {
  _W(head);
  putchar(sizeof...(tail) ? ' ' : '\n');
  W(tail...);
}
const int N = 2e6 + 10;
const long long MOD = 1e9 + 7;
vector<int> primes;
int p_tbl[N];
void sieve() {
  p_tbl[1] = 1;
  for (int i = 2; i < N; i++) {
    if (!p_tbl[i]) {
      primes.push_back(i);
      p_tbl[i] = i;
    }
    for (int p : primes) {
      int x = i * p;
      if (x >= N) break;
      p_tbl[x] = p;
      if (i % p == 0) break;
    }
  }
}
long long inv[N], fac[N], ifac[N];
void predo() {
  inv[1] = 1;
  for (int i = (2); i <= int(N - 1); i++)
    inv[i] = inv[MOD % i] * (MOD - MOD / i) % MOD;
  fac[0] = 1;
  for (int i = (1); i <= int(N - 1); i++) fac[i] = fac[i - 1] * i % MOD;
  ifac[0] = 1;
  for (int i = (1); i <= int(N - 1); i++) ifac[i] = ifac[i - 1] * inv[i] % MOD;
}
long long C(int n, int m) { return fac[n] * ifac[m] % MOD * ifac[n - m] % MOD; }
long long F(int n, int m) { return C(n + m, n); }
int main() {
  sieve();
  predo();
  int q;
  R(q);
  while (q--) {
    int r, n;
    R(r, n);
    long long ans = 1;
    while (n > 1) {
      int p = p_tbl[n];
      int e = 1;
      n /= p;
      while (n % p == 0) {
        e++;
        n /= p;
      }
      long long now = 0;
      now += F(r, e - 1);
      now += F(r, e);
      ans = (ans * now) % MOD;
    }
    W(ans);
  }
  return 0;
}