#include using namespace std; const int64_t M = 1'000'000'007; enum rangeOperaion{ NUL, UPDATE, ADD }; class segTree{ int N; int64_t e = 0; struct{ int64_t operator()(int64_t a, int64_t b){ return (a+b) % M; } } func; int64_t *tree; pair *lazy; const pair I=make_pair(NUL, 0); pair *range; int getParent(int child){ return child/2; } pair getChildren(int parent){ return make_pair(2*parent, 2*parent+1); } int lg(int64_t N){ int lgN; for(lgN=0;(1< val){ if(val.first==UPDATE) lazy[pos]=val; else if(lazy[pos].first==NUL) lazy[pos]=val; else lazy[pos].second+=val.second; } void eval(int pos){ if(lazy[pos].first==NUL) return; if(pos[2*N]; range=new pair[2*N]; for(int i=1;i<2*N;i++){ tree[i]=e; lazy[i]=I; } for(int i=2*N-1;i>0;i--){ if(i>=N) range[i]=make_pair(i-N, i-N+1); else range[i]=make_pair(range[getChildren(i).first].first, range[getChildren(i).second].second); } } ~segTree(){ delete[] tree; delete[] lazy; delete[] range; } void update(int64_t value, int left, int right){ assert(0<=left && left> n >> m >> k; vector> lr; for(int i=0;i> l >> r; lr.push_back({l-1, r}); } segTree st[2] = {n, n}; st[0].update(1, 0); for(int s=1;s<=k;s++){ st[s%2].update(0, 0, n); for(auto e:lr){ st[s%2].add(st[(s+1)%2].queue(e.first, e.second), e.first, e.second); } } cout << st[n%2].queue(n-1) << endl; return 0; }