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 pair<int, int> DD[] = {{1, 0},  {1, 1},   {0, 1},  {-1, 1},
                             {-1, 0}, {-1, -1}, {0, -1}, {1, -1}};
inline int readChar();
template <class T = int>
inline T readInt();
template <class T>
inline void writeInt(T first, char end = 0);
inline void writeChar(int first);
inline void writeWord(const char *s);
static const int buf_size = 4096;
inline int getChar() {
  static char buf[buf_size];
  static int len = 0, pos = 0;
  if (pos == len) pos = 0, len = fread(buf, 1, buf_size, stdin);
  if (pos == len) return -1;
  return buf[pos++];
}
inline int readChar() {
  int c = getChar();
  while (c <= 32) c = getChar();
  return c;
}
template <class T>
inline T readInt() {
  int s = 1, c = readChar();
  T first = 0;
  if (c == '-') s = -1, c = getChar();
  while ('0' <= c && c <= '9') first = first * 10 + c - '0', c = getChar();
  return s == 1 ? first : -first;
}
static int write_pos = 0;
static char write_buf[buf_size];
inline void writeChar(int first) {
  if (write_pos == buf_size)
    fwrite(write_buf, 1, buf_size, stdout), write_pos = 0;
  write_buf[write_pos++] = first;
}
template <class T>
inline void writeInt(T first, char end) {
  if (first < 0) writeChar('-'), first = -first;
  char s[24];
  int n = 0;
  while (first || !n) s[n++] = '0' + first % 10, first /= 10;
  while (n--) writeChar(s[n]);
  if (end) writeChar(end);
}
inline void writeWord(const char *s) {
  while (*s) writeChar(*s++);
}
struct Flusher {
  ~Flusher() {
    if (write_pos) fwrite(write_buf, 1, write_pos, stdout), write_pos = 0;
  }
} flusher;
int32_t main(void) {
  srand(time(0));
  cout << fixed << setprecision(7);
  cerr << fixed << setprecision(7);
  static int f[1 << 21];
  static int c[1 << 21];
  f[0] = c[0] = 1;
  const int N = 1e6 + 55;
  const int mod = 1e9 + 7;
  auto pow = [&](int a, int b, int mod) {
    int ans = 1;
    while (b) {
      if (b & 1) ans = (1ll * ans * a) % mod;
      b /= 2;
      a = (1ll * a * a) % mod;
    }
    return ans;
  };
  for (int i = 1; i <= N; ++i) {
    f[i] = (1ll * f[i - 1] * i) % mod;
    c[i] = (1ll * c[i - 1] * pow(i, mod - 2, mod)) % mod;
  }
  auto C = [&](int n, int k) {
    if (!(0 <= k && k <= n)) return (int)(0);
    int ans = f[n];
    ans = (1ll * ans * c[k]) % mod;
    ans = (1ll * ans * c[n - k]) % mod;
    return ans;
  };
  auto shit = [&](int power, int how) {
    int ans = (C(how + power - 1, how) + C(how + power, how)) % mod;
    return ans;
  };
  static vector<int> dv[1 << 21];
  for (int i = 2; i <= N; ++i)
    if (dv[i].empty())
      for (int j = i; j <= N; j += i) {
        int cnt = 0, pidar = j;
        while (!(pidar % i)) ++cnt, pidar /= i;
        dv[j].push_back(cnt);
      }
  int q = readInt();
  while (q--) {
    int suka = readInt();
    int n = readInt();
    int ans = 1;
    for (auto it : dv[n]) ans = (1ll * ans * shit(it, suka)) % mod;
    writeInt(ans, '\n');
  }
  cerr << "Time elapsed :" << clock() * 1000.0 / CLOCKS_PER_SEC << " ms"
       << '\n';
  return 0;
}