#include using namespace std; #include using namespace atcoder; using ll = long long; using P = pair; #define fix(x) fixed << setprecision(x) #define asc(x) x, vector, greater #define rep(i, n) for(ll i = 0; i < n; i++) #define all(x) (x).begin(),(x).end() templatebool chmin(T&a, const T&b){if(a>b){a=b;return 1;}return 0;} templatebool chmax(T&a, const T&b){if(a> h >> w >> n >> p; vector

x(n); rep(i,n) cin >> x[i].first >> x[i].second; sort(all(x)); segtree seg(w); rep(i,n) seg.set(x[i].second-1, seg.prod(0,x[i].second)+1); ll a1 = (p-1) * mpow(p, MOD-2) % MOD, a2 = (p-2) * mpow(p, MOD-2) % MOD, k = seg.all_prod(); cout << (MOD+1-mpow(a2,k)*mpow(a1,h+w-3-k)%MOD) % MOD << '\n'; return 0; }