#include #define rep(i,n) for(int i=0;i ; using pll = pair; const int INF = 1e9; const ll LINF = 1e18; const int MOD = 1000000007; struct LazySegmentTree{ int n; vector node; vector lazy; ll inv2 = MOD - (MOD / 2) % MOD; LazySegmentTree(vector v){ int sz = v.size(); n = 1; while(n < sz) n *= 2; node.resize(2*n-1,0); lazy.resize(2*n-1,0); for(int i=0;i=0;i--) node[i] = (node[2*i+1] + node[2*i+2])%MOD; } void eval(int k){ if(lazy[k] == 0) return; if(k < n - 1){ lazy[2*k+1] = (lazy[2*k+1] + (lazy[k] * inv2)%MOD)%MOD; lazy[2*k+2] = (lazy[2*k+2] + (lazy[k] * inv2)%MOD)%MOD; } node[k] = (node[k] + lazy[k])%MOD; lazy[k] = 0; } //[a,b) の区間全てにxを足す。 void update(int a,int b,long long x,int k=0,int l=0,int r=-1){ eval(k); if(r < 0) r = n; if(a <= l && r <= b){ lazy[k] = (lazy[k] + ((r - l) * x)%MOD)%MOD; eval(k); }else if(a < r && l < b){ update(a,b,x,2*k+1,l,(l+r)/2); update(a,b,x,2*k+2,(l+r)/2,r); node[k] = (node[2*k+1] + node[2*k+2])%MOD; } } //[a,b) の区間の総和を求める。 long long query(int a,int b,int k=0,int l=0,int r=-1){ eval(k); if(r < 0) r = n; if(r <= a || b <= l) return 0; if(a <= l && r <= b) return node[k]; long long vl = query(a,b,2*k+1,l,(l+r)/2); long long vr = query(a,b,2*k+2,(l+r)/2,r); return (vl + vr)%MOD; } }; int main(){ int n,m,k; cin >> n >> m >> k; vector

lr(m); rep(i,m){ cin >> lr[i].first >> lr[i].second; --lr[i].first; --lr[i].second; } vector a(n,0); a[0] = 1; LazySegmentTree seg_prev(a); LazySegmentTree seg(vector(n,0)); rep(i,k){ rep(j,m){ ll plus = seg_prev.query(lr[j].first,lr[j].second+1); seg.update(lr[j].first,lr[j].second+1,plus); } swap(seg,seg_prev); LazySegmentTree empty(vector(n,0)); swap(empty,seg); } cout << seg_prev.query(n-1,n) << endl; return 0; }