#include <bits/stdc++.h>
using namespace std;
int read() {
  int x = 0, f = 1;
  char ch = getchar();
  while (ch - '0' < 0 || ch - '0' > 9) {
    if (ch == '-') f = -1;
    ch = getchar();
  }
  while (ch - '0' >= 0 && ch - '0' <= 9) {
    x = x * 10 + ch - '0';
    ch = getchar();
  }
  return x * f;
}
int prime[1000010], primesize;
bool notprime[1000010];
int las[1000010];
void pre() {
  notprime[1] = true;
  for (int i = 2; i <= 1000000; i++) {
    if (!notprime[i]) prime[++primesize] = i, las[i] = i;
    for (int j = 1; j <= primesize && i * prime[j] <= 1000000; j++) {
      notprime[i * prime[j]] = true;
      las[i * prime[j]] = prime[j];
      if (i % prime[j] == 0) break;
    }
  }
}
int f[1000010][22];
int mix(int x, int y) {
  return (x + y >= 1000000007) ? x + y - 1000000007 : x + y;
}
void add(int &x, int y) { x = mix(x, y); }
int main() {
  pre();
  f[0][0] = 1;
  for (int i = 1; i <= 20; i++) f[0][i] = 2;
  for (int i = 1; i <= 1000000; i++)
    for (int j = 0; j <= 20; j++) f[i][j] = mix(f[i][j - 1], f[i - 1][j]);
  int T = read();
  while (T--) {
    int r = read(), n = read();
    int ans = 1;
    while (n != 1) {
      int e = 0, fac = las[n];
      while (n % fac == 0) n /= fac, e++;
      ans = 1ll * ans * f[r][e] % 1000000007;
    }
    printf("%d\n", ans);
  }
  return 0;
}
