R=range H,W,K,M=map(int,input().split()) HW=H*W p=1<<HW found=[0]*((p+31)>>5) count=[0]*(HW+1) dfs=[] for h in R(H): for w in R(W): i=h*W+w s=1<<i found[s>>5]|=1<<(s&31) bs=0 for dx,dy in zip([-1,0,1,0],[0,-1,0,1]): if 0<=h+dx<H and 0<=w+dy<W: j=i+dx*W+dy bs|=(1<<j) dfs+=[[s,bs]] while dfs: s,bs=dfs.pop() c=s.bit_count() count[c]+=1<<(HW-c-bs.bit_count()) for i in R(HW): if(bs>>i)&1<1:continue h,w=i//W,i%W t=s|(1<<i) if(found[t>>5]>>(t&31))&1:continue; found[t>>5]|=1<<(t&31) bt=bs^(1<<i) for dx,dy in zip([-1,0,1,0],[0,-1,0,1]): if 0<=h+dx<H and 0<=w+dy<W: j=i+dx*W+dy if(s>>j)&1<1:bt|=(1<<j) dfs+=[[t,bt]] print(sum(pow(c,K,M)*count[c]for c in R(1,HW+1))*sum(pow(HW-n+1,-1,M)for n in R(1,HW+1))*pow(2,-HW,M)%M)