#include <bits/stdc++.h>
using namespace std;
int dp[1000005][25];
int p[1000005];
int sum(long long a, long long b) {
  long long ans = (a + b);
  if (ans > 1000000007) ans %= 1000000007;
  return int(ans);
}
int mul(long long a, long long b) {
  long long ans = (a * b);
  if (ans > 1000000007) ans %= 1000000007;
  return int(ans);
}
void sieve() {
  for (int i = 0; i < 1000005; i++) p[i] = i;
  for (int i = 2; i < 1000005; i++) {
    if (p[i] == i) {
      for (int j = i + i; j < 1000005; j += i) p[j] = i;
    }
  }
}
int main() {
  ios_base::sync_with_stdio(false);
  int n, r, ans = 0, tc;
  sieve();
  for (int i = 0; i < 1000005; i++) {
    dp[i][0] = 1;
    for (int j = 1; j < 25; j++) {
      if (i == 0)
        dp[0][j] = 2;
      else
        dp[i][j] = sum(dp[i][j - 1], dp[i - 1][j]);
    }
  }
  scanf("%d", &tc);
  while (tc--) {
    ans = 1;
    scanf("%d%d", &r, &n);
    while (n != 1) {
      int cnt = 0;
      int k = p[n];
      while (n % k == 0) {
        n /= k;
        cnt++;
      }
      ans = mul(ans, dp[r][cnt]);
    }
    printf("%d\n", ans);
  }
}
