#include <bits/stdc++.h>
const int MAXN = 1e6 + 1, P = 1e9 + 7;
int i, j, k, n, q, r, d[MAXN], f[MAXN][20];
int main() {
  for (i = 2; i < MAXN; i++)
    if (!d[i])
      for (j = i; j < MAXN; j += i) d[j] = i;
  for (i = 0; i < MAXN; *f[i++] = 1)
    ;
  for (d[1] = i = 1; i < 20; f[0][i++] = 2)
    ;
  for (i = 1; i < MAXN; i++)
    for (j = 1; j < 20; j++) f[i][j] = (f[i][j - 1] + f[i - 1][j]) % P;
  for (scanf("%d", &q); q--; printf("%d\n", r)) {
    scanf("%d%d", &k, &n);
    for (r = 1; n > 1; r = 1ll * r * f[k][i] % P)
      for (j = d[n], i = 0; n % j == 0; n /= j) i++;
  }
}
