#include <bits/stdc++.h>
typedef long long ll;
using namespace std;
// ———— change #1: prime modulus 10^9+7 ————
const ll mod = 10000007;
// fast i/o / debug timers left untouched
void Code_By_Mohamed_Khaled() {
ios_base::sync_with_stdio(false);
cin.tie(nullptr);
cout.tie(nullptr);
#ifndef ONLINE_JUDGE
freopen("input.txt", "r", stdin);
freopen("output.txt", "w", stdout);
#endif
}
void Time() {
#ifndef ONLINE_JUDGE
cout<<"\n";
auto end = chrono::high_resolution_clock::now();
auto duration = chrono::duration_cast<chrono::microseconds>(end - chrono::high_resolution_clock::now());
cout << "Time taken: " << duration.count() << " microseconds" << endl;
#endif
}
// safe modular ops
ll add(ll a, ll b) { return (a + b) % mod; }
ll mul(ll a, ll b) { return (a * b) % mod; }
ll sub(ll a, ll b) { return (a - b + mod) % mod; }
// ———— SPF sieve up to 1e6 ————
static const int MAXN = 1000000;
vector<int> spf(MAXN+1, 1);
void precompute_spf() {
for (int i = 2; i <= MAXN; i++) {
if (spf[i] == 1) {
for (ll j = i; j <= MAXN; j += i) {
if (spf[j] == 1) spf[j] = i;
}
}
}
}
// fast exponentiation (only used for inv‑build below)
ll fast_power(ll base, ll exp) {
ll res = 1;
while (exp) {
if (exp & 1) res = mul(res, base);
base = mul(base, base);
exp >>= 1;
}
return res;
}
// ———— change #2: build inv[] up to mod ————
vector<ll> inv; // size will be mod+5
void build_inverses() {
inv.resize(mod+5);
inv[1] = 1;
for (int i = 2; i < mod; i++) {
// only valid because mod is prime
inv[i] = mul(mod - mod/i, inv[mod % i]);
}
}
// factor n by SPF
void prime_fact(ll n, vector<pair<int,int>>& fac) {
while (n > 1) {
int p = spf[n], cnt = 0;
while (n % p == 0) {
n /= p;
cnt++;
}
fac.emplace_back(p, cnt);
}
}
// ans[i] = sndd(i!) mod
vector<ll> ans(MAXN+1);
int main(){
Code_By_Mohamed_Khaled();
precompute_spf();
build_inverses();
// orig[p] = current exponent of prime p in (i-1)!
vector<int> orig(MAXN+1, 0);
// x = running product of [ (e_p+1)*(e_p+2)/2 ] over all primes p seen so far
ll x = 1;
auto get_sum = [&](ll e)->ll {
// (e+1)(e+2)/2 mod
ll t = mul(e+1, e+2);
return mul(t, inv[2]);
};
// precompute ans[1..MAXN]
for (int i = 1; i <= MAXN; i++) {
vector<pair<int,int>> fac;
prime_fact(i, fac);
for (auto &it : fac) {
int p = it.first;
int cnt = it.second;
ll old_e = orig[p];
ll new_e = old_e + cnt;
ll old_sum = get_sum(old_e);
ll new_sum = get_sum(new_e);
// divide out the old prime‐term, multiply in the new one
x = mul(x, new_sum);
x = mul(x, inv[old_sum]);
orig[p] = new_e;
}
ans[i] = x;
}
// answer queries
ll n;
while (cin >> n && n > 0) {
cout << ans[n] << "\n";
}
Time();
return 0;
}