#include <bits/stdc++.h>
using namespace std;
template <class T>
inline void read(T& num) {
  num = 0;
  bool f = true;
  char ch = getchar();
  while (ch < '0' || ch > '9') {
    if (ch == '-') f = false;
    ch = getchar();
  }
  while (ch >= '0' && ch <= '9') {
    num = num * 10 + ch - '0';
    ch = getchar();
  }
  num = f ? num : -num;
}
int out[100];
template <class T>
inline void write(T x, char ch) {
  if (x == 0) {
    putchar('0');
    putchar(ch);
    return;
  }
  if (x < 0) {
    putchar('-');
    x = -x;
  }
  int num = 0;
  while (x) {
    out[num++] = (x % 10);
    x = x / 10;
  }
  for (int i = (num - 1); i >= (0); i--) putchar(out[i] + '0');
  putchar(ch);
}
const double eps = 1e-8;
long long f[1000005][22];
bool a[1000005];
long long c[1000005], cnt = 0;
int prime[1000005];
void get() {
  long long i = 2;
  for (; i < 1000005; i++) {
    if (!a[i]) prime[++cnt] = i;
    for (long long j = 1; j <= cnt && i * prime[j] < 1000005; j++) {
      a[i * prime[j]] = true;
      if (i % prime[j] == 0) break;
    }
  }
}
long long sum[1000005];
int main() {
  f[0][0] = 1;
  sum[0] = 1;
  for (int i = (1); i <= (21); i++) f[0][i] = 2, sum[i] = sum[i - 1] + f[0][i];
  for (int i = (1); i <= (1000005); i++) {
    for (int j = (0); j <= (21); j++) f[i][j] = sum[j];
    for (int j = (0); j <= (21); j++)
      sum[j] = j == 0 ? 1 : sum[j - 1] + f[i][j], sum[j] %= 1000000007;
  }
  get();
  int cas;
  read(cas);
  while (cas--) {
    int r, n;
    long long ans = 1;
    read(r);
    read(n);
    for (int i = 1; i <= cnt && (prime[i]) * (prime[i]) <= n; i++) {
      if (n % prime[i] == 0) {
        int tmp = 0;
        while (n % prime[i] == 0 && n != 1) tmp++, n /= prime[i];
        ans = ans * f[r][tmp] % 1000000007;
      }
    }
    if (n > 1) ans = ans * f[r][1] % 1000000007;
    write(ans, '\n');
  }
}
