#include <bits/stdc++.h>
using namespace std;
int tot, n, r, f[1000020][21];
int prime[1000020], v[1000020], top;
void init() {
  top = 0;
  for (int i = 2; i < 1000020; ++i) {
    if (!v[i]) prime[++top] = i;
    for (int j = 1; j <= top && prime[j] * i < 1000020; ++j) {
      v[i * prime[j]] = 1;
      if (i % prime[j] == 0) break;
    }
  }
  for (int i = 0; i < 1000020; ++i) f[i][0] = 1;
  for (int i = 1; i < 21; ++i) f[0][i] = 2;
  for (int i = 1; i < 1000020; ++i)
    for (int j = 1; j < 21; ++j)
      f[i][j] = (f[i - 1][j] + f[i][j - 1]) % 1000000007;
}
int main() {
  init();
  scanf("%d", &tot);
  while (tot--) {
    scanf("%d%d", &r, &n);
    long long ans = 1;
    for (int i = 1; i <= top && prime[i] * prime[i] <= n; ++i) {
      if (n % prime[i] == 0) {
        int k = 0;
        while (n % prime[i] == 0) ++k, n /= prime[i];
        (ans *= f[r][k]) %= 1000000007;
      }
    }
    if (n > 1) (ans *= f[r][1]) %= 1000000007;
    printf("%d\n", (int)ans);
  }
  return 0;
}
