#include <bits/stdc++.h>
using namespace std;
const int maxn = 1e6 + 7;
const int mod = 1e9 + 7;
const int INF = 1e9 + 7;
const int maxl = 20;
const int SQ = 400;
int dp[maxn][maxl];
int mark[maxn];
void prep() {
  for (int i = 2; i < maxn; i++) {
    if (mark[i]) continue;
    for (int j = i; j < maxn; j += i) mark[j] = i;
  }
  for (int i = 0; i < maxn; i++)
    for (int j = 0; j < maxl; j++)
      dp[i][j] =
          (i > 0 ? (dp[i - 1][j] + (j > 0 ? dp[i][j - 1] : 0)) % mod : 2 - !j);
}
int main() {
  prep();
  int q;
  scanf("%d", &q);
  while (q--) {
    int r, n;
    scanf("%d%d", &r, &n);
    long long ans = 1;
    for (int i = mark[n]; n > 1; i = mark[n]) {
      int cnt = 0;
      while (n % i == 0) cnt++, n /= i;
      ans = (1ll * ans * dp[r][cnt]) % mod;
    }
    printf("%lld\n", ans);
  }
  return 0;
}
