#include using namespace std; #define INF 1234567890 #define ll long long #define MOD 998244353 ll pw(ll a, ll n) { ll ret = 1; while(n) { if (n&1) ret=ret*a%MOD; a=a*a%MOD; n >>= 1; } return ret; } ll inv(ll a) { return pw(a, MOD-2); } int N, M, K, P; int fen[200001]; int Max(int idx) { int ret = 0; while(idx) { ret = max(ret, fen[idx]); idx &= idx-1; } return ret; } void Add(int idx, int val) { while(idx <= 200000) { fen[idx] = max(fen[idx], val); idx += idx & -idx; } } int main() { ios::sync_with_stdio(0); cin.tie(0); cin.exceptions(ios::badbit | ios::failbit); cin >> N >> M >> K >> P; vector > v; for(int i=0; i> y >> x; v.push_back({y, x}); } v.push_back({N, M}); sort(v.begin(), v.end()); for(auto [y,x] : v) { int dp = Max(x) + 1; Add(x, dp); if (y == N && x == M) { int cnt = dp - 1; int dnt = N+M-1 - cnt - 2; ll cval = 2 * inv(P) % MOD; ll dval = inv(P); ll res = 1; while(cnt--) res *= (1-cval), res %= MOD; while(dnt--) res *= (1-dval), res %= MOD; res = 1-res; res %= MOD; res += MOD; res %= MOD; cout << res << "\n"; break; } } return 0; }