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 long long N = 1e6 + 100;
const long long mod = 1e9 + 7;
vector<pair<long long, long long> > a[N];
long long rev[N], f[N];
void check(long long x) {
  for (long long i = 0; i < a[x].size(); i++) {
    long long tmp = x;
    while (tmp % a[x][i].first == 0) {
      tmp /= a[x][i].first;
      a[x][i].second++;
    }
  }
}
long long choose(long long n, long long k) {
  long long ans = (f[n] * rev[k]) % mod;
  ans *= rev[n - k];
  ans %= mod;
  return ans;
}
long long tavan(long long n, long long k) {
  if (k == 0) return 1;
  n %= mod;
  long long ans = tavan(n, k / 2);
  ans *= ans;
  ans %= mod;
  if (k % 2 == 1) ans *= n;
  ans %= mod;
  return ans;
}
int32_t main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  long long q;
  cin >> q;
  f[0] = 1;
  rev[0] = 1;
  for (long long i = 1; i < N; i++) {
    f[i] = (f[i - 1] * i) % mod;
  }
  rev[N - 1] = tavan(f[N - 1], mod - 2);
  for (long long i = N - 2; i >= 1; i--) {
    rev[i] = (rev[i + 1] * (i + 1)) % mod;
  }
  for (long long i = 2; i < N; i++) {
    if (a[i].size() != 0) continue;
    for (long long j = i; j < N; j += i) {
      a[j].push_back(make_pair(i, 0));
    }
  }
  for (long long i = 2; i < N; i++) check(i);
  for (long long _ = 0, r, n; _ < q; _++) {
    cin >> r >> n;
    long long ans = 1;
    for (long long i = 0, x; i < a[n].size(); i++) {
      x = a[n][i].second;
      ans *= (choose(x + r, r) + choose(x + r - 1, r)) % mod;
      ans %= mod;
    }
    cout << ans << "\n";
  }
  return 0;
}