#include using namespace std; #include using namespace atcoder; using mint = modint998244353; using vm = vector; using vvm = vector; inline ostream &operator<<(ostream &os, const mint x) { return os << x.val(); }; inline istream &operator>>(istream &is, mint &x) { long long v; is >> v; x = v; return is; }; struct Fast { Fast() { std::cin.tie(nullptr); ios::sync_with_stdio(false); cout << setprecision(10); } } fast; #define all(a) (a).begin(), (a).end() #define contains(a, x) ((a).find(x) != (a).end()) #define rep(i, a, b) for (int i = (a); i < (int)(b); i++) #define rrep(i, a, b) for (int i = (int)(b) - 1; i >= (a); i--) #define YN(b) cout << ((b) ? "YES" : "NO") << "\n"; #define Yn(b) cout << ((b) ? "Yes" : "No") << "\n"; #define yn(b) cout << ((b) ? "yes" : "no") << "\n"; template inline bool chmin(T &a, T b) { if (a > b) { a = b; return true; } return false; } template inline bool chmax(T &a, T b) { if (a < b) { a = b; return true; } return false; } using ll = long long; using vb = vector; using vvb = vector; using vi = vector; using vvi = vector; using vl = vector; using vvl = vector; template ostream &operator<<(ostream &os, pair &p) { os << "(" << p.first << "," << p.second << ")"; return os; } template ostream &operator<<(ostream &os, vector &vec) { for (int i = 0; i < (int)vec.size(); i++) { os << vec[i] << (i + 1 == (int)vec.size() ? "" : " "); } return os; } template istream &operator>>(istream &is, vector &vec) { for (int i = 0; i < (int)vec.size(); i++) is >> vec[i]; return is; } ll floor(ll a, ll b) { return a >= 0 ? a / b : (a + 1) / b - 1; } ll ceil(ll a, ll b) { return a > 0 ? (a - 1) / b + 1 : a / b; } struct dsu_ { public: dsu_() : _n(0) {} explicit dsu_(int n) : _n(n), parent_or_size(n, -1) {} void clear() { fill(all(parent_or_size), -1); } int merge(int a, int b) { assert(0 <= a && a < _n); assert(0 <= b && b < _n); int x = leader(a), y = leader(b); if (x == y) return x; if (-parent_or_size[x] < -parent_or_size[y]) std::swap(x, y); parent_or_size[x] += parent_or_size[y]; parent_or_size[y] = x; return x; } int leader(int a) { assert(0 <= a && a < _n); if (parent_or_size[a] < 0) return a; return parent_or_size[a] = leader(parent_or_size[a]); } int size(int a) { assert(0 <= a && a < _n); return -parent_or_size[leader(a)]; } private: int _n; // root node: -1 * component size // otherwise: parent std::vector parent_or_size; }; void solve() { int h, w, m; ll k; cin >> h >> w >> k >> m; using mint = dynamic_modint<0>; mint::set_mod(m); vi cnt(h * w + 1, 0); dsu_ uf(h * w); for (int bit = 0; bit < (1 << (h * w)); bit++) { uf.clear(); for (int i = 0; i < h; i++) for (int j = 0; j + 1 < w; j++) if (((bit >> (w * i + j)) & 1) & ((bit >> (w * i + j + 1)) & 1)) uf.merge(w * i + j, w * i + j + 1); for (int i = 0; i + 1 < h; i++) for (int j = 0; j < w; j++) if (((bit >> (w * i + j)) & 1) & ((bit >> (w * i + j + w)) & 1)) uf.merge(w * i + j, w * i + j + w); for (int i = 0; i < h * w; i++) if (((bit >> i) & 1) == 1 && uf.leader(i) == i) cnt[uf.size(i)]++; } mint ans = 0; rep(i, 0, h * w + 1) ans += mint(i).pow(k) * cnt[i]; mint p = 0; rep(i, 1, h * w + 1) p += mint(i).inv(); ans *= p; ans *= mint(2).inv().pow(h * w); cout << ans.val() << "\n"; } int main() { int t = 1; // cin >> t; while (t--) solve(); }