#include <bits/stdc++.h>
using namespace std;
const int MAX = 1e6 + 1, MOD = 1e9 + 7;
int n, r, t, f[MAX][20], p[MAX];
int main() {
  f[0][0] = 1;
  for (int i = 1; i < 20; i++) f[0][i] = 2;
  for (int i = 1; i < MAX; i++) {
    f[i][0] = 1;
    for (int j = 1; j < 20; j++) f[i][j] = (f[i][j - 1] + f[i - 1][j]) % MOD;
  }
  for (int i = 4; i < MAX; i += 2) p[i] = 2;
  for (int i = 3; i * i < MAX; i += 2) {
    if (p[i] > 0) continue;
    for (int j = 2 * i; j < MAX; j += i) p[j] = i;
  }
  scanf("%d", &t);
  while (t--) {
    scanf("%d%d", &r, &n);
    vector<int> v;
    while (p[n]) {
      v.push_back(p[n]);
      n /= p[n];
    }
    if (n > 1) v.push_back(n);
    sort(v.begin(), v.end());
    int c = 1, sol = 1;
    for (int i = 0; i < (int)v.size(); i++) {
      if (i == (int)v.size() - 1 || v[i] != v[i + 1]) {
        sol = (sol * 1LL * f[r][c]) % MOD;
        c = 1;
      } else
        c++;
    }
    printf("%d\n", sol);
  }
  return 0;
}
