#line 1 "a.cpp" #include #include #include using namespace std; #line 3 "/home/kotatsugame/library/math/modint.cpp" #include template struct modint{ unsigned int x; constexpr modint()noexcept:x(){} template constexpr modint(T x_)noexcept:x((x_%=m)<0?x_+m:x_){} constexpr unsigned int val()const noexcept{return x;} constexpr modint&operator++()noexcept{if(++x==m)x=0;return*this;} constexpr modint&operator--()noexcept{if(x==0)x=m;--x;return*this;} constexpr modint operator++(int)noexcept{modint res=*this;++*this;return res;} constexpr modint operator--(int)noexcept{modint res=*this;--*this;return res;} constexpr modint&operator+=(const modint&a)noexcept{x+=a.x;if(x>=m)x-=m;return*this;} constexpr modint&operator-=(const modint&a)noexcept{if(x>=1)if(n&1)r*=x; return r; } constexpr modint inv()const noexcept { int s=x,t=m,x=1,u=0; while(t) { int k=s/t; s-=k*t; swap(s,t); x-=k*u; swap(x,u); } return modint(x); } friend constexpr modint operator+(const modint&a,const modint&b){return modint(a)+=b;} friend constexpr modint operator-(const modint&a,const modint&b){return modint(a)-=b;} friend constexpr modint operator*(const modint&a,const modint&b){return modint(a)*=b;} friend constexpr modint operator/(const modint&a,const modint&b){return modint(a)/=b;} friend constexpr bool operator==(const modint&a,const modint&b){return a.x==b.x;} friend constexpr bool operator!=(const modint&a,const modint&b){return a.x!=b.x;} friend ostream&operator<<(ostream&os,const modint&a){return os<>(istream&is,modint&a){long long v;is>>v;a=modint(v);return is;} }; #line 6 "a.cpp" using mint=modint<998244353>; mint fac[2<<17],inv[2<<17]; mint comb(int a,int b){return fac[a]*inv[b]*inv[a-b];} int N,M,L,K; int Xc[1<<17],Yc[1<<17]; vector >G[1<<17]; mint dp[1<<17][101]; mint ep[111][101]; mint F[111]; main() { fac[0]=1; for(int i=1;i<2<<17;i++)fac[i]=fac[i-1]*i; inv[(2<<17)-1]=1/fac[(2<<17)-1]; for(int i=(2<<17)-1;i--;)inv[i]=inv[i+1]*(i+1); cin>>N>>M>>L>>K; for(int i=1;i<=M;i++)cin>>Xc[i]>>Yc[i]; Xc[M+1]=Yc[M+1]=N; if(K>=L) { mint ans=1; for(int i=1;i<=M+1;i++) { int dx=Xc[i]-Xc[i-1]; int dy=Yc[i]-Yc[i-1]; ans*=comb(dx+dy,dx); } cout<>x>>y; for(int i=0;iy||Yc[id+1]y) { if(Yc[id-1]<=y) { G[id-1].push_back(make_pair(x,y)); } } else if(Yc[id+1] >pt=G[i]; pt.push_back(make_pair(Xc[i],Yc[i])); pt.push_back(make_pair(Xc[i+1],Yc[i+1])); sort(pt.begin(),pt.end()); pt.erase(unique(pt.begin(),pt.end()),pt.end()); for(int j=0;jrx||ly>ry)continue; mint now=comb(rx-lx+ry-ly,rx-lx); for(int m=j+1;m