#include #define MOD 1000000007LL using namespace std; typedef long long ll; typedef pair P; class segtree{ public: int N; vector dp; segtree(){ } void init(int n){ N=1; while(N0){ k=(k-1)/2; dp[k]=dp[k*2+1]*dp[k*2+2]%MOD; } } ll query(int a,int b,int k,int l,int r){ if(b<=l || r<=a)return 1; if(a<=l && r<=b)return dp[k]; int mid=(l+r)/2; ll vl=query(a,b,k*2+1,l,mid); ll vr=query(a,b,k*2+2,mid,r); return vl*vr%MOD; } ll query(int a,int b){ return query(a,b,0,0,N); } }; class segtree2{ public: int N; vector dp; segtree2(){ } void init(int n,int w){ N=1; while(N0){ k=(k-1)/2; dp[k].update(w,v); } } ll query(int a,int b,int ax,int bx,int k,int l,int r){ if(b<=l || r<=a)return 1; if(a<=l && r<=b)return dp[k].query(ax,bx); int mid=(l+r)/2; ll vl=query(a,b,ax,bx,k*2+1,l,mid); ll vr=query(a,b,ax,bx,k*2+2,mid,r); return vl*vr%MOD; } ll query(int a,int b,int ax,int bx){ return query(a,b,ax,bx,0,0,N); } }; segtree2 segT; int h,w,q; int main(void){ scanf("%d%d",&h,&w); segT.init(h,w); ll su=0; for(int i=0;i