#include <bits/stdc++.h>
#define MP make_pair
#define PB push_back
#define int long long
#define st first
#define nd second
#define rd third
#define FOR(i, a, b) for(int i =(a); i <=(b); ++i)
#define RE(i, n) FOR(i, 1, n)
#define FORD(i, a, b) for(int i = (a); i >= (b); --i)
#define REP(i, n) for(int i = 0;i <(n); ++i)
#define VAR(v, i) __typeof(i) v=(i)
#define FORE(i, c) for(VAR(i, (c).begin()); i != (c).end(); ++i)
#define ALL(x) (x).begin(), (x).end()
#define SZ(x) ((int)(x).size())
#define __builtin_ctz __builtin_ctzll
#define __builtin_clz __builtin_clzll
#define __builtin_popcount __builtin_popcountll
using namespace std;
template<typename TH> void _dbg(const char* sdbg, TH h) { cerr<<sdbg<<"="<<h<<"\n"; }
template<typename TH, typename... TA> void _dbg(const char* sdbg, TH h, TA... t) {
while(*sdbg != ',')cerr<<*sdbg++; cerr<<"="<<h<<","; _dbg(sdbg+1, t...);
}
#ifdef LOCAL
#define debug(...) _dbg(#__VA_ARGS__, __VA_ARGS__)
#define debugv(x) {{cerr <<#x <<" = "; FORE(itt, (x)) cerr <<*itt <<", "; cerr <<"\n"; }}
#else
#define debug(...) (__VA_ARGS__)
#define debugv(x)
#define cerr if(0)cout
#endif
#define next ____next
#define prev ____prev
#define left ____left
#define hash ____hash
typedef long long ll;
typedef long double LD;
typedef pair<int, int> PII;
typedef pair<ll, ll> PLL;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<ll> VLL;
typedef vector<pair<int, int> > VPII;
typedef vector<pair<ll, ll> > VPLL;
template<class C> void mini(C&a4, C b4){a4=min(a4, b4); }
template<class C> void maxi(C&a4, C b4){a4=max(a4, b4); }
template<class T1, class T2>
ostream& operator<< (ostream &out, pair<T1, T2> pair) { return out << "(" << pair.first << ", " << pair.second << ")";}
template<class A, class B, class C> struct Triple { A first; B second; C third;
bool operator<(const Triple& t) const { if (st != t.st) return st < t.st; if (nd != t.nd) return nd < t.nd; return rd < t.rd; } };
template<class T> void ResizeVec(T&, vector<int>) {}
template<class T> void ResizeVec(vector<T>& vec, vector<int> sz) {
vec.resize(sz[0]); sz.erase(sz.begin()); if (sz.empty()) { return; }
for (T& v : vec) { ResizeVec(v, sz); }
}
typedef Triple<int, int, int> TIII;
template<class A, class B, class C>
ostream& operator<< (ostream &out, Triple<A, B, C> t) { return out << "(" << t.st << ", " << t.nd << ", " << t.rd << ")"; }
template<class T> ostream& operator<<(ostream& out, vector<T> vec) { out<<"("; for (auto& v: vec) out<<v<<", "; return out<<")"; }
template<class T> ostream& operator<<(ostream& out, set<T> vec) { out<<"("; for (auto& v: vec) out<<v<<", "; return out<<")"; }
template<class L, class R> ostream& operator<<(ostream& out, map<L, R> vec) { out<<"("; for (auto& v: vec) out<<v<<", "; return out<<")"; }
const int K = 52;
int dp[2][K][K][K * K / 2];
int P;
void Add(int& a, int b) {
a += b;
if (a >= P) {
a -= P;
}
}
void Sub(int& a, int b) {
a -= b;
if (a < 0) {
a += P;
}
}
const int N = 3000;
int newt[N][N];
int32_t main() {
ios_base::sync_with_stdio(0);
cout << fixed << setprecision(10);
cerr << fixed << setprecision(10);
cin.tie(0);
//double beg_clock = 1.0 * clock() / CLOCKS_PER_SEC;
int n, m, k;
cin>>n>>m>>k>>P;
dp[0][0][0][0] = 1;
int nxt = 1;
RE (i, n) {
FOR (wyn, 0, k) {
FOR (last_end, 0, i - 1) {
FOR (luzne, 0, i * (i - 1) / 2 + 5) {
dp[nxt][wyn][last_end][luzne] = 0;
}
}
}
FOR (wyn, 0, k) {
FOR (last_end, 0, i - 1) {
FOR (luzne, 0, i * (i - 1) / 2) {
// 1 case - wyn sie nie zwieksza
// wszystkie poczatki sa <= last_end,
// zatem luzne zwieksza sie o last_end
Add(dp[nxt][wyn][last_end][luzne + last_end], dp[nxt ^ 1][wyn][last_end][luzne]);
if (luzne + last_end > 0) {
Sub(dp[nxt][wyn][last_end][luzne + last_end - 1], dp[nxt ^ 1][wyn][last_end][luzne]);
}
// 2 case - wyn sie zwieksza
// mam kogos z poczatkiem > last_end
// jak koniec to x, to luzne zwieksza sie o x - 1
// zatem na przedziale od luzne+last_end do luzne+i-1 zwiekszam od tyle
Add(dp[nxt][wyn + 1][i][luzne + i - 1], dp[nxt ^ 1][wyn][last_end][luzne]);
if(luzne + last_end > 0) {
Sub(dp[nxt][wyn + 1][i][luzne + last_end - 1], dp[nxt ^ 1][wyn][last_end][luzne]);
}
}
}
}
// robie sumy sufiksowe po luzne
FOR (wyn, 0, k) {
FOR (last_end, 0, i) {
FORD (luzne, n * (n + 1) / 2, 0) {
Add(dp[nxt][wyn][last_end][luzne], dp[nxt][wyn][last_end][luzne + 1]);
}
}
}
nxt ^= 1;
}
REP (i, N) {
newt[i][0] = newt[i][i] = 1;
}
REP (i, N) {
RE (j, i - 1) {
newt[i][j] = (newt[i - 1][j] + newt[i - 1][j - 1]) % P;
}
}
int res = 0;
FOR (last_end, 0, n) {
FOR (luzne, 0, n * (n + 1) / 2) {
int to_take = m - k;
debug(to_take, dp[nxt ^ 1][k][last_end][luzne], last_end, luzne);
Add(res, dp[nxt ^ 1][k][last_end][luzne] * newt[luzne][to_take] % P);
}
}
cout<<res<<endl;
return 0;
}
I2luY2x1ZGUgPGJpdHMvc3RkYysrLmg+CiNkZWZpbmUgTVAgbWFrZV9wYWlyCiNkZWZpbmUgUEIgcHVzaF9iYWNrCiNkZWZpbmUgaW50IGxvbmcgbG9uZwojZGVmaW5lIHN0IGZpcnN0CiNkZWZpbmUgbmQgc2Vjb25kCiNkZWZpbmUgcmQgdGhpcmQKI2RlZmluZSBGT1IoaSwgYSwgYikgZm9yKGludCBpID0oYSk7IGkgPD0oYik7ICsraSkKI2RlZmluZSBSRShpLCBuKSBGT1IoaSwgMSwgbikKI2RlZmluZSBGT1JEKGksIGEsIGIpIGZvcihpbnQgaSA9IChhKTsgaSA+PSAoYik7IC0taSkKI2RlZmluZSBSRVAoaSwgbikgZm9yKGludCBpID0gMDtpIDwobik7ICsraSkKI2RlZmluZSBWQVIodiwgaSkgX190eXBlb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tIHd5biBzaWUgbmllIHp3aWVrc3phCiAgICAgICAgICAvLyB3c3p5c3RraWUgcG9jemF0a2kgc2EgPD0gbGFzdF9lbmQsCiAgICAgICAgICAvLyB6YXRlbSBsdXpuZSB6d2lla3N6YSBzaWUgbyBsYXN0X2VuZAogICAgICAgICAgQWRkKGRwW254dF1bd3luXVtsYXN0X2VuZF1bbHV6bmUgKyBsYXN0X2VuZF0sIGRwW254dCBeIDFdW3d5bl1bbGFzdF9lbmRdW2x1em5lXSk7CiAgICAgICAgICBpZiAobHV6bmUgKyBsYXN0X2VuZCA+IDApIHsKICAgICAgICAgICAgU3ViKGRwW254dF1bd3luXVtsYXN0X2VuZF1bbHV6bmUgKyBsYXN0X2VuZCAtIDFdLCBkcFtueHQgXiAxXVt3eW5dW2xhc3RfZW5kXVtsdXpuZV0pOwogICAgICAgICAgfQogICAgICAgICAgLy8gMiAgY2FzZSAtIHd5biBzaWUgendpZWtzemEKICAgICAgICAgIC8vIG1hbSBrb2dvcyB6IHBvY3phdGtpZW0gPiBsYXN0X2VuZAogICAgICAgICAgLy8gamFrIGtvbmllYyB0byB4LCB0byBsdXpuZSB6d2lla3N6YSBzaWUgbyB4IC0gMQogICAgICAgICAgLy8gemF0ZW0gbmEgcHJ6ZWR6aWFsZSBvZCBsdXpuZStsYXN0X2VuZCBkbyBsdXpuZStpLTEgendpZWtzemFtIG9kIHR5bGUKICAgICAgICAgIEFkZChkcFtueHRdW3d5biArIDFdW2ldW2x1em5lICsgaSAtIDFdLCBkcFtueHQgXiAxXVt3eW5dW2xhc3RfZW5kXVtsdXpuZV0pOwogICAgICAgICAgaWYobHV6bmUgKyBsYXN0X2VuZCA+IDApIHsKICAgICAgICAgICAgU3ViKGRwW254dF1bd3luICsgMV1baV1bbHV6bmUgKyBsYXN0X2VuZCAtIDFdLCBkcFtueHQgXiAxXVt3eW5dW2xhc3RfZW5kXVtsdXpuZV0pOwogICAgICAgICAgfQogICAgICAgIH0KICAgICAgfQogICAgfQogICAgLy8gcm9iaWUgc3VteSBzdWZpa3Nvd2UgcG8gbHV6bmUKICAgIEZPUiAod3luLCAwLCBrKSB7CiAgICAgIEZPUiAobGFzdF9lbmQsIDAsIGkpIHsKICAgICAgICBGT1JEIChsdXpuZSwgbiAqIChuICsgMSkgLyAyLCAwKSB7CiAgICAgICAgICBBZGQoZHBbbnh0XVt3eW5dW2xhc3RfZW5kXVtsdXpuZV0sIGRwW254dF1bd3luXVtsYXN0X2VuZF1bbHV6bmUgKyAxXSk7CiAgICAgICAgfQogICAgICB9CiAgICB9CiAgICBueHQgXj0gMTsKICB9CiAgUkVQIChpLCBOKSB7CiAgICBuZXd0W2ldWzBdID0gbmV3dFtpXVtpXSA9IDE7CiAgfQogIFJFUCAoaSwgTikgewogICAgUkUgKGosIGkgLSAxKSB7CiAgICAgIG5ld3RbaV1bal0gPSAobmV3dFtpIC0gMV1bal0gKyBuZXd0W2kgLSAxXVtqIC0gMV0pICUgUDsKICAgIH0KICB9CiAgaW50IHJlcyA9IDA7CiAgRk9SIChsYXN0X2VuZCwgMCwgbikgewogICAgRk9SIChsdXpuZSwgMCwgbiAqIChuICsgMSkgLyAyKSB7CiAgICAgIGludCB0b190YWtlID0gbSAtIGs7CiAgICAgIGRlYnVnKHRvX3Rha2UsIGRwW254dCBeIDFdW2tdW2xhc3RfZW5kXVtsdXpuZV0sIGxhc3RfZW5kLCBsdXpuZSk7CiAgICAgIEFkZChyZXMsIGRwW254dCBeIDFdW2tdW2xhc3RfZW5kXVtsdXpuZV0gKiBuZXd0W2x1em5lXVt0b190YWtlXSAlIFApOwogICAgfQogIH0KICBjb3V0PDxyZXM8PGVuZGw7CiAgICAKICAgIAogIAogIAogIAogIAogIAogIAogIAogIAogIAogIAogIAogIAogIAogIAogIAogIAogIAogIAogIAogIAogIAogIAogIAogIAogIHJldHVybiAwOwp9