#include<cstdio>
typedef long long LL;
const int N=2003;
const int O=2*N;
int n,m,ans;
int dp[3*N][5*N];

inline LL Pow(LL x,int p) {
	if(p==0) return 1;
	if(!(p&1)) return Pow(x*x%m,p>>1);
	return x*Pow(x*x%m,p>>1)%m;
}
inline void Add(int &x,int y) {
	x+=y; if(x>=m) x-=m;
}
int main() {
	scanf("%d %d",&n,&m); n*=3;
	dp[0][O]=1;
	for(int s=0;s<=n;s++) {
		for(int D=-s/2;D<=s;D++) {
			int d=D+O;
			Add(dp[s+1][d+1],dp[s][d]);
			Add(dp[s+2][d-1],dp[s][d]*(s+1ll)%m);
			Add(dp[s+3][d],dp[s][d]*(s+1ll)%m*(s+2ll)%m);
		}
	}
	for(int i=0;i<=n;i+=3)
		Add(ans,dp[n][i+O]);
	printf("%d\n",ans);
	return 0;
}
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
//#include <boost/multiprecision/cpp_int.hpp>
//typedef boost::multiprecision::cpp_int ll;
typedef long double dd;
#define i_7 (ll)(1E9+7)
//#define i_7 998244353
#define i_5 i_7-2
ll mod(ll a){
    ll c=a%i_7;
    if(c>=0)return c;
    return c+i_7;
}
typedef pair<ll,ll> l_l;
ll inf=(ll)1E16;
#define rep(i,l,r) for(ll i=l;i<=r;i++)
#define pb push_back
ll max(ll a,ll b){if(a<b)return b;else return a;}
ll min(ll a,ll b){if(a>b)return b;else return a;}
void Max(ll &pos,ll val){pos=max(pos,val);}//Max(dp[n],dp[n-1]);
void Min(ll &pos,ll val){pos=min(pos,val);}
void Add(ll &pos,ll val){pos=mod(pos+val);}
dd EPS=1E-9;
#define fastio ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);

ll hpow(ll x,ll y){
    ll ans=1;
    ll i=x;
    if(y==0)return 1;
    while(y>0){
        if(y%2==1){
            ans=(ans*i)%i_7;
        }
        i=(i*i)%i_7;
        y=y/2;
        
    }
    return ans;
}

ll memop[2000000];
ll mkai(ll i){
    if(i==0){
        return 1;
    }
    if(memop[i]!=0){
        return memop[i];
    }else{
        ll ans=(mkai(i-1)*hpow(i,i_7-2))%i_7;
        memop[i]=ans;
        return ans;
    }
}

ll memok[2000000];
ll kai(ll i){
    if(i==0){
        return 1;
    }
    if(memok[i]!=0){
        return memok[i];
    }else{
        ll ans=(kai(i-1)*i)%i_7;
        memok[i]=ans;
        return ans;
    }
}

ll comb(ll n,ll k){
    ll ans=(kai(n)*mkai(k))%i_7;
    ans=(ans*mkai(n-k))%i_7;
    return ans;
}

int main(){
    ll h,w,a,b;cin>>h>>w>>a>>b;
    ll ans=0;
    rep(i,b,w-1){
        ans=(ans+(comb(h-a-1+i,h-a-1)*comb(a-1+w-1-i,a-1))%i_7)%i_7;
    }
    cout<<ans<<endl;
    return 0;
}
