#include <bits/stdc++.h>
int dp[1000000 + 10][20 + 1], lp[1000000 + 10], prime[1000000], tot;
bool vis[1000000 + 10];
using namespace std;
const long long mod = 1e9 + 7;
void init() {
  for (int i = (2); i <= (1000000); ++i) {
    if (!vis[i]) {
      prime[tot++] = i;
      lp[i] = i;
    }
    for (int j = (0); j < (tot); ++j) {
      if (i * prime[j] > 1000000) break;
      vis[i * prime[j]] = true;
      lp[i * prime[j]] = prime[j];
      if (i % prime[j] == 0) break;
    }
  }
  for (int i = (1); i <= (20); ++i) dp[0][i] = 2;
  for (int i = (1); i <= (1000000); ++i) {
    dp[i][0] = 1;
    for (int j = (1); j <= (20); ++j)
      dp[i][j] = (dp[i][j - 1] + dp[i - 1][j]) % mod;
  }
}
long long calc(int n, int r) {
  long long ans = 1;
  while (n > 1) {
    int pr = lp[n], cnt = 0;
    while (n % pr == 0) ++cnt, n /= pr;
    (ans *= dp[r][cnt]) %= mod;
  }
  return ans;
}
int main() {
  init();
  int T;
  scanf("%d", &T);
  while (T--) {
    int n, r;
    scanf("%d%d", &r, &n);
    printf("%I64d\n", calc(n, r));
  }
  return 0;
}
