#include const int bit[26] = {1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8192, 16384, 32768, 65536, 131072, 262144, 524288, 1048576, 2097152, 4194304, 8388608, 16777216, 33554432}; int Mod; long long pow[26]; long long div_mod(long long x, long long y, long long z) { if (x % y == 0) return x / y; else return (div_mod((1 + x / y) * y - x, (z % y), y) * z + x) / y; } long long pow_mod(int n, long long k) { if (n == 0) return 0; long long N, ans = 1; for (N = n; k > 0; k >>= 1, N = N * N % Mod) if (k & 1) ans = ans * N % Mod; return ans; } long long calc(int H, int W, int x) { int i, j, k; static char S[30][30] = {}; for (i = 1, k = 0; i <= H; i++) { for (j = 1; j <= W; j++, k++) { if ((x & bit[k]) != 0) S[i][j] = '.'; else S[i][j] = '#'; } } int ii, jj; static int q[26][2], head, tail; long long ans = 0; for (ii = 1; ii <= H; ii++) { for (jj = 1; jj <= W; jj++) { if (S[ii][jj] == '#') continue; S[ii][jj] = '#'; q[0][0] = ii; q[0][1] = jj; for (head = 0, tail = 1; head < tail; head++) { i = q[head][0]; j = q[head][1]; if (S[i-1][j] == '.') { S[i-1][j] = '#'; q[tail][0] = i - 1; q[tail++][1] = j; } if (S[i+1][j] == '.') { S[i+1][j] = '#'; q[tail][0] = i + 1; q[tail++][1] = j; } if (S[i][j-1] == '.') { S[i][j-1] = '#'; q[tail][0] = i; q[tail++][1] = j - 1; } if (S[i][j+1] == '.') { S[i][j+1] = '#'; q[tail][0] = i; q[tail++][1] = j + 1; } } ans += pow[tail]; } } return ans % Mod; } int main() { int H, W; long long K; scanf("%d %d %lld %d", &H, &W, &K, &Mod); int i, x; long long tmp, inv[26], invv = div_mod(1, pow_mod(2, H * W), Mod), ans = 0; for (i = 1, pow[0] = 0; i <= H * W; i++) { inv[i] = div_mod(1, i, Mod); pow[i] = pow_mod(i, K); } for (x = 0; x < bit[H*W]; x++) ans += calc(H, W, x); for (i = 1, tmp = 0; i <= H * W; i++) tmp += inv[i]; tmp %= Mod; ans = ans % Mod * invv % Mod * tmp % Mod; printf("%lld\n", ans % Mod); fflush(stdout); return 0; }