#include <bits/stdc++.h>
using namespace std;
const int N = 1000005;
const int mod = 1000000007;
void add(int &x, int y) {
  if ((x += y) >= mod) x -= mod;
}
int d[21][N];
int lp[N], pr[N], len = 0;
void precalc() {
  for (int r = 0; r <= 1000000; ++r) d[0][r] = 1;
  for (int i = 1; i < 20; ++i) d[i][0] = 2;
  for (int r = 1; r <= 1000000; ++r)
    for (int i = 1; i < 20; ++i) {
      d[i][r] = d[i - 1][r];
      add(d[i][r], d[i][r - 1]);
    }
  for (int i = 2; i <= 1000000; ++i) {
    if (!lp[i]) {
      lp[i] = i;
      pr[++len] = i;
    }
    for (int j = 1; j <= len && i * 1ll * pr[j] <= 1000000 && pr[j] <= lp[i];
         ++j)
      lp[pr[j] * i] = pr[j];
  }
}
inline int calc(int &r, int &n) {
  int res = 1;
  while (n > 1) {
    int x = lp[n], cnt = 0;
    while (n % x == 0) {
      n /= x;
      ++cnt;
    }
    res = res * 1ll * d[cnt][r] % mod;
  }
  return res;
}
int main() {
  precalc();
  int q;
  scanf("%d", &q);
  while (q--) {
    int r, n;
    scanf("%d%d", &r, &n);
    printf("%d\n", calc(r, n));
  }
  return 0;
}
