#include<bits/stdc++.h>
#define PI acos(-1.0)
#define eps 1e-67
#define pf printf
#define sf scanf
#define sd(n) scanf("%d",&n)
#define sd2(n1,n2) scanf("%d %d",&n1,&n2)
#define slf(n) scanf("%lf",&n)
#define slf2(n1,n2) scanf("%lf %lf",&n1,&n2)
#define sLf(n1) scanf("%Lf",&n1)
#define sLf2(n1,n2) scanf("%Lf %Lf",&n1,&n2)
#define sl(n) scanf("%lld",&n)
#define sl2(n1,n2) scanf("%lld %lld",&n1,&n2)
#define rep(i,a,b) for(long long int i=a;i<b;i++)
#define repb(i,a,b) for(long long int i=a;i>=b;i--)
#define repa(i,a,b,c) for(long long int i=a;i<b;i=i+c)
#define reps(i,a,b,c) for(long long int i=a;i>b;i=i-c)
#define asort(a) sort(a.begin(),a.end())
#define asortb(a,comp) sort(a.begin(),a.end(),comp)
#define arev(a) reverse(a.begin(),a.end())
#define all(v) (v).begin(),(v).end()
#define allc(v,comp) (v).begin(),(v).end(),comp
#define allrc(v,a,b,comp) (v).begin()+a,(v).end()-b,comp
#define F first
#define S second
#define pb push_back
#define eb emplace_back
#define pbb pop_back
#define mp make_pair
#define mt make_tuple
#define bs(v,x) binary_search(v.begin(),v.end(),x)
#define lb(v,x) lower_bound(v.begin(),v.end(),x)
#define ub(v,x) upper_bound(v.begin(),v.end(),x)
#define tl(c) towlower(c)
#define root(x) sqrt(x)
#define power(a,n) (int)floor(pow(a,n))
#define tu(c) towupper(c)
#define sq(a) ((a)*(a))
#define cube(a) ((a)*(a)*(a))
#define mx 1000
#define MX 100000
#define mod 1000000007
using namespace std;
typedef string str;
typedef long long int ll;
typedef double lf;
typedef long double llf;
typedef unsigned long long int ull;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef pair<int,int> pi;
typedef pair<ll,ll> pll;
typedef vector<pll> vpll;
typedef char ch;
typedef map<ll,ll> mp;
void Solve()
{
    ll n;
    cin>>n;
    vll v;
    bool prime[100000];
    memset(prime, true, sizeof(prime));
    prime[0]=prime[1]=false;
    for (ll p=2; p<=n; p++)
    {

        if (prime[p] == true)
        {

            for (ll i=p*p; i<=n; i += p)
                prime[i] = false;
        }
    }
    ll i,j,sum=0,ans=1;
    rep(i,0,n+1)
    {
        if(prime[i])
        {
            v.pb(i);

        }
    }

    rep(i,0,v.size())
    {
        rep(j,1,10){
            sum+=(n/power(v[i],j));
        }
        ans*=(sum+1);
        ans%=mod;
        sum=0;
    }
    cout<<ans<<endl;
}

int main()
{
    Solve();
    return 0;
}

#include<bits/stdc++.h>
using namespace std;
#define fs first
#define sc second
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define ALL(A) A.begin(),A.end()
#define RALL(A) A.rbegin(),A.rend()
typedef long long LL;
typedef pair<LL,LL> P;
const LL mod=1000000007;
const LL LINF=1LL<<60;
const int INF=1<<30;
int dx[]={1,0,-1,0};
int dy[]={0,1,0,-1};



int main(){
    int n,m;cin >> n >> m;
    vector<int> a(n),b(m);
    for (int i = 0; i < n; i++) {
        cin >> a[i];
    }
    sort(RALL(a));
    for (int i = 0; i < m; i++) {
        cin >> b[i];
    }
    sort(RALL(b));
    LL h=0,w=0;
    LL ans = 1, res = 0;
    for (int i = n*m; i >= 1; i--) {
        if(h < n && i == a[h] && w < m && i == b[w]){
            h++;
            w++;
            res += h + w - 2;
        }
        else if(h < n && i == a[h]){
            if(w==0) ans = 0;
            h++;
            res += w - 1;
            ans = ans * w % mod;
        }
        else if(w < m && i == b[w]){
            if(h==0) ans = 0;
            w++;
            res += h - 1;
            ans = ans * h % mod;
        }
        else{
            if(res <= 0) ans = 0;
            ans = ans * res % mod;
            res--;
        }
    }
    cout << ans << endl;
    return 0;
}
