#include #include using namespace atcoder; using namespace std; using ll=long long; using ld=double; ld pie=3.14159265359; ll mod=998244353; ll inf=100000; ll op(ll a,ll b){ return max(a,b); } ll e(){ return -1; } int main(){ ll h,w,n,p; cin >> h >> w >> n >> p; vectorx(n),y(n); vector>pp(n); for (ll i = 0; i < n; i++) { cin >> x[i] >> y[i]; pp[i]={x[i],y[i]}; } sort(pp.begin(),pp.end()); vectora(w+1,0); segtreeseg(a); for (ll i = 0; i < n; i++) { ll x=seg.prod(0,pp[i].second+1); seg.set(pp[i].second,x+1); } ll dai=seg.all_prod(); ll hiku=1; ll bo=1; for (ll i = 0; i