#include <bits/stdc++.h>
using namespace std;
const int maxn = 1000000 + 5;
const int mod = 1000000007;
int dp[maxn][21];
int lp[maxn];
void init() {
  lp[1] = 1;
  for (long long i = 2; i < maxn; i++) {
    if (!lp[i]) {
      for (long long j = i; j < maxn; j = j + i) lp[j] = i;
    }
  }
  for (int i = 0; i < 21; i++) dp[0][i] = 2;
  for (int i = 0; i < maxn; i++) dp[i][0] = 1;
  for (int i = 1; i < maxn; i++)
    for (int j = 1; j < 21; j++) dp[i][j] = (dp[i][j - 1] + dp[i - 1][j]) % mod;
}
int main() {
  init();
  int q;
  scanf("%d", &q);
  for (int i = 0; i < q; i++) {
    int r, n;
    scanf("%d%d", &r, &n);
    long long ans = 1;
    int tmp = n;
    int p = lp[tmp];
    while (tmp != 1) {
      int x = 0;
      while (tmp % p == 0) {
        tmp = tmp / p;
        x++;
      }
      ans = (ans * dp[r][x]) % mod;
      p = lp[tmp];
    }
    printf("%d\n", ans);
  }
  return 0;
}
