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 N = 2e6 + 7;
const int mod = 1e9 + 7;
void upd(int& x, int y) {
  x += y;
  if (x >= mod) x -= mod;
}
int qpow(int a, int b) {
  int aa = a, res = 1;
  for (; b; b >>= 1) {
    if (b & 1) res = 1ll * res * aa % mod;
    aa = 1ll * aa * aa % mod;
  }
  return res;
}
int bin[N], pin[N];
void init() {
  bin[0] = pin[0] = 1;
  for (int i = 1; i <= N - 1; i++) bin[i] = 1ll * bin[i - 1] * i % mod;
  pin[N - 1] = qpow(bin[N - 1], mod - 2);
  for (int i = N - 2; i >= 1; i--) pin[i] = 1ll * pin[i + 1] * (i + 1) % mod;
}
int C(int x, int y) { return 1ll * bin[x] * pin[x - y] % mod * pin[y] % mod; }
int n, p[N], top = 0, Q, lc[N], lv[N], vis[N];
void init2() {
  int lim = N - 1;
  for (int i = 2; i <= lim; i++) {
    if (!vis[i]) {
      p[++top] = i;
      lv[i] = i;
      lc[i] = 1;
    }
    for (int k = 1; k <= top; k++) {
      if (1ll * i * p[k] > lim) break;
      vis[i * p[k]] = 1;
      if (i % p[k]) {
        lv[i * p[k]] = p[k];
        lc[i * p[k]] = 1;
      } else {
        lv[i * p[k]] = lv[i] * p[k];
        lc[i * p[k]] = lc[i] + 1;
        break;
      }
    }
  }
}
int f(int k, int r) {
  return (1ll * 2 * C(r + k - 1, r) + 1ll * C(r + k - 1, r - 1)) % mod;
}
int main() {
  init();
  init2();
  scanf("%d", &Q);
  int n, r;
  while (Q--) {
    scanf("%d%d", &r, &n);
    int ans = 1;
    while (n != 1) {
      ans = 1ll * ans * f(lc[n], r) % mod;
      n /= lv[n];
    }
    printf("%d\n", ans);
  }
}