Problem: For each of the K^{NM} ways to write an integer between 1 and K (inclusive) in every square in a square grid with N rows and M columns, find the value defined below, then compute the sum of all those K^{NM} values, modulo D.

* For each of the NM squares, find the minimum among the N+M-1 integers written in the square's row or the square's column. The value defined for the grid is the product of all these NM values.

Constraints

* 1 \leq N,M,K \leq 100
* 10^8 \leq D \leq 10^9
* N,M,K, and D are integers.
* D is prime.

Input

Input is given from Standard Input in the following format:


N M K D


Output

Print the sum of the K^{NM} values, modulo D.

Examples

Input

2 2 2 998244353


Output

35


Input

2 3 4 998244353


Output

127090


Input

31 41 59 998244353


Output

827794103

Solution (in CPP):

Solution:
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int n,m,K,mod;
inline int add(int a,int b){a+=b;return a>=mod?a-mod:a;}
inline int sub(int a,int b){a-=b;return a<0?a+mod:a;}
inline int mul(int a,int b){return 1ll*a*b%mod;}
inline int qpow(int a,int b){int ret=1;for(;b;b>>=1,a=mul(a,a))if(b&1)ret=mul(ret,a);return ret;}
/* math */
const int N = 110;
int bin[N][N];
int c=0,f[2][N][N],cst[N][N];
int fac[N], ifac[N], pw[N][N*N];
int main()
{
	cin >> n >> m >> K >> mod;
	for(int i=0;i<=K;i++){
		pw[i][0]=1;for(int j=1;j<=n*m;j++)pw[i][j]=mul(pw[i][j-1],i);
	}
	fac[0]=ifac[0]=1;for(int i=1;i<=max(n,m);i++)fac[i] = mul(fac[i-1],i);
	ifac[max(n,m)]=qpow(fac[max(n,m)],mod-2);for(int j=max(n,m)-1;j;j--)ifac[j]=mul(ifac[j+1],j+1);
	f[c][0][0]=1;
	for(int D = 1;D<=K;D++){
		c^=1;memset(f[c],0,sizeof(f[c]));
		for(int j=0;j<=n;j++)
		for(int k=0;k<=m;k++){
			cst[j][k] = mul(mul(ifac[j],pw[D-1][j*(m-k)]), mul(pw[K-D+1][j*k], j%2?mod-1:1));
		}
		for(int i=0;i<=n;i++)for(int j=0;j<=m;j++){
			for(int k=0;k<=i;k++){
				f[c][i][j]=add(f[c][i][j], mul(f[c^1][i-k][j], cst[k][j]));
			}
		}
		// cout << f[c][0][0] << " " << f[c][0][1] << " " << f[c][1][0] << " " << f[c][1][1] << endl;
		c^=1;memset(f[c],0,sizeof(f[c]));
		for(int j=0;j<=m;j++)
		for(int k=0;k<=n;k++){
			cst[j][k] = mul(mul(ifac[j],pw[D-1][j*(n-k)]), mul(pw[K-D+1][j*k], j%2?mod-1:1));
		}
		for(int i=0;i<=n;i++)for(int j=0;j<=m;j++){
			for(int k=0;k<=j;k++){
				f[c][i][j]=add(f[c][i][j], mul(f[c^1][i][j-k], cst[k][i]));
			}
		}
		// cout << f[c][0][0] << " " << f[c][0][1] << " " << f[c][1][0] << " " << f[c][1][1] << endl;
		c^=1;memset(f[c],0,sizeof(f[c]));
		for(int j=0;j<=n;j++)
		for(int k=0;k<=m;k++){
			cst[j][k] = mul(mul(ifac[j],pw[D][j*(m-k)]), mul(pw[K-D+1][j*k], 1));
		}
		for(int i=0;i<=n;i++)for(int j=0;j<=m;j++){
			for(int k=0;k<=i;k++){
				f[c][i][j]=add(f[c][i][j], mul(f[c^1][i-k][j], cst[k][j]));
			}
		}
		
		//  cout << f[c][0][0] << " " << f[c][0][1] << " " << f[c][1][0] << " " << f[c][1][1] << endl;
		c^=1;memset(f[c],0,sizeof(f[c]));
		for(int j=0;j<=m;j++)
		for(int k=0;k<=n;k++){
			cst[j][k] = mul(mul(ifac[j],pw[D][j*(n-k)]), mul(pw[K-D+1][j*k], 1));
		}
		for(int i=0;i<=n;i++)for(int j=0;j<=m;j++){
			for(int k=0;k<=j;k++){
				f[c][i][j]=add(f[c][i][j], mul(f[c^1][i][j-k], cst[k][i]));
			}
		}
		
		//  cout << f[c][0][0] << " " << f[c][0][1] << " " << f[c][1][0] << " " << f[c][1][1] << endl;
	}
	cout << mul(f[c][n][m], mul(fac[n],fac[m])) << endl;
}