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;
bool home = 1;
signed realMain();
signed main() {
  home = 0;
  if (home) {
    freopen("tony_stark", "r", stdin);
  } else {
    ios::sync_with_stdio(0);
    cin.tie(0);
  }
  realMain();
}
class linearSieve {
 public:
  vector<int> primes;
  vector<int> lp;
  void put(int Limit) {
    primes.clear();
    lp.clear();
    lp.resize(Limit + 1, 0);
    for (int i = 2; i <= Limit; i++) {
      if (!lp[i]) {
        lp[i] = i;
        primes.push_back(i);
      }
      for (int j = 0; j < (int)primes.size() && primes[j] * i <= Limit &&
                      primes[j] <= lp[i];
           j++) {
        lp[primes[j] * i] = primes[j];
      }
    }
  }
} user;
const int M = (int)1e9 + 7;
int add(int a, int b) {
  a += b;
  if (a >= M) return a - M;
  if (a < 0) return a + M;
  return a;
}
int mul(int a, int b) { return a * (long long)b % M; }
int pw(int a, int b) {
  int r = 1;
  while (b) {
    if (b & 1) r = mul(r, a);
    a = mul(a, a);
    b /= 2;
  }
  return r;
}
int dv(int a, int b) { return mul(a, pw(b, M - 2)); }
const int N = (int)1e6 + 12345 + 7;
int fact[N], ifact[N];
int tab[N];
int comb(int n, int k) {
  if (k < 0 || k > n) return 0;
  return mul(fact[n], mul(ifact[k], ifact[n - k]));
}
int get(int r, int n) {
  vector<int> divis;
  for (int j = 1; j <= n; j *= 2) {
    divis.push_back(j);
  }
  int ret = 0;
  for (auto &i : divis) {
    int x = tab[i];
    int coef = 1;
    int y = n / i;
    while (y > 1) {
      int d = user.lp[y], cnt = 0;
      while (y % d == 0) {
        y /= d;
        cnt++;
      }
      coef = mul(coef, comb(cnt + r - 1, cnt));
    }
    ret = add(ret, mul(x, coef));
  }
  return ret;
}
signed realMain() {
  fact[0] = 1;
  for (int i = 1; i < N; i++) fact[i] = mul(fact[i - 1], i);
  ifact[N - 1] = dv(1, fact[N - 1]);
  for (int i = N - 2; i >= 0; i--) ifact[i] = mul(ifact[i + 1], i + 1);
  user.put(N);
  for (int i = 1; i < N; i++) {
    tab[i] = 1;
    int x = i;
    while (x > 1) {
      int d = user.lp[x];
      while (x % d == 0) {
        x /= d;
      }
      tab[i] *= 2;
    }
  }
  int q;
  cin >> q;
  while (q--) {
    int r, n, ret = 1;
    cin >> r >> n;
    while (n > 1) {
      int num = 0, val = user.lp[n];
      while (n % val == 0) {
        num++;
        n /= val;
      }
      ret = mul(ret, get(r, 1 << num));
    }
    cout << ret << "\n";
  }
  return 0;
}