#include <bits/stdc++.h>
using namespace std;
const int N = 1e6 + 15, mod = 1e9 + 7;
int d[N], f[N][20];
int main() {
  for (int i = 2; i < N; ++i) {
    if (!d[i]) {
      for (int j = i; j < N; j += i) {
        d[j] = i;
      }
    }
  }
  for (int i = 0; i < N; ++i) {
    *f[i] = 1;
  }
  d[1] = 1;
  for (int i = 1; i < 20; ++i) {
    f[0][i] = 2;
  }
  for (int i = 1; i < N; ++i) {
    for (int j = 1; j < 20; ++j) {
      f[i][j] = (f[i][j - 1] + f[i - 1][j]) % mod;
    }
  }
  int q = 0, k = 0, n = 0;
  scanf("%d", &q);
  while (q--) {
    scanf("%d%d", &k, &n);
    long long r = 1LL;
    while (n > 1) {
      int j = d[n], cnt = 0;
      while (n % j == 0) {
        n /= j;
        ++cnt;
      }
      r = 1LL * r * f[k][cnt] % mod;
    }
    printf("%I64d\n", r);
  }
  return 0;
}
