#include #include using namespace std; long mod=1e8+7; long power(long a,long b){return b?power(a*a%mod,b/2)*(b%2?a:1)%mod:1;} long F[2<<17],I[2<<17]; long C(int N,int K){return F[N]*I[N-K]%mod*I[K]%mod;} int H,W,K; pairab[20]; long A[1<<20]; main() { F[0]=1; for(int i=1;i<2<<17;i++)F[i]=F[i-1]*i%mod; I[(2<<17)-1]=power(F[(2<<17)-1],mod-2); for(int i=(2<<17)-1;i--;)I[i]=I[i+1]*(i+1)%mod; cin>>H>>W>>K; for(int i=0;i>ab[i].first>>ab[i].second; sort(ab,ab+K); for(int i=0;i<1<>j&1) { pc++; if(nx<=ab[j].first&&ny<=ab[j].second) { int dx=ab[j].first-nx,dy=ab[j].second-ny; ans=ans*C(dx+dy,dx)%mod; nx=ab[j].first; ny=ab[j].second; } else ans=0; } } int dx=H-nx,dy=W-ny; ans=ans*C(dx+dy,dx)%mod; A[i]=pc%2?mod-ans:ans; } for(int i=0;i>i&1)(A[j]+=A[j^1<