#include <bits/stdc++.h>
using namespace std;
char CRTBUFF[30000];
struct debugger {
  static void call(const char* it) {}
  template <typename T, typename... aT>
  static void call(const char* it, T a, aT... rest) {
    string b;
    for (; *it && *it != ','; ++it)
      if (*it != ' ') b += *it;
    cerr << b << "=" << a << " ";
    call(++it, rest...);
  }
};
long long add(long long a, long long b) { return (a + b) % 1000000007; }
long long mul(long long a, long long b) { return (a * b) % 1000000007; }
bool composite[1000010 + 10];
vector<int> primes;
int dp[1000010 + 10][30];
int func(int r, int x) {
  if (r == 0) return (x ? 2 : 1);
  auto& ret = dp[r][x];
  if (ret != -1) return ret;
  ret = 0;
  for (int i = (0); i < (x + 1); i += (1)) ret = add(ret, func(r - 1, i));
  return ret;
}
void init() {
  int lim = sqrt(1000010);
  for (int i = (2); i < (lim); i += (1))
    if (!composite[i]) {
      for (int j = i * i; j <= 1000010; j += i) {
        composite[j] = true;
      }
    }
  for (int i = (2); i < (1000010); i += (1))
    if (!composite[i]) {
      primes.push_back(i);
    }
  memset(dp, 0, sizeof(dp));
  for (int j = (0); j < (30); j += (1)) dp[0][j] = (j ? 2 : 1);
  for (int i = (1); i < (1000010); i += (1))
    for (int j = (0); j < (21); j += (1)) {
      long long ret = 0;
      for (int k = (0); k < (j + 1); k += (1)) {
        ret += dp[i - 1][k];
      }
      dp[i][j] = ret % 1000000007;
    }
}
int main() {
  init();
  int TC;
  scanf("%d", &TC);
  for (int cs = (1); cs < (TC + 1); cs += (1)) {
    int r, n;
    scanf("%d%d", &r, &n);
    int ans = 1;
    for (auto p : primes) {
      if (((long long)p) * p > n) break;
      if (n % p == 0) {
        int cnt = 0;
        while (n % p == 0) n = n / p, cnt++;
        ans = mul(ans, dp[r][cnt]);
      }
    }
    if (n > 1) ans = mul(ans, dp[r][1]);
    printf("%d\n", ans);
  }
}
